|
Posted by raylopez99 on 07/15/07 00:05
Problem:
I replicated, using Frasier "Pro Visual C++/CLI" (2006), Chap 12, a
database that has a relationship between two tables, called Content
and Author, using a common column, called "AuthorID". I used the
Server Explorer insider Visual Studio 2005 to do this. It worked.
Now I tried the exact same thing from Visual Studio 2005 but this time
using C# not C++ as my language of choice. The interface is slightly
different, but I made sure everything was done as before. I used the
Server Explorer 'GUI' to do this, clicking and following the 'wizards'
as before.
But somehow, when using C# rather than C++, I get this error when
attempting to create a relationship between tables when using two
identical columns called "AuthorID": "the columns in table Authors do
not match an existing primary key or UNIQUE constraint" Why? The
columns are the same. I even tried (and this made no difference)
copying and pasting columns from one table to the other, but still I
get this error.
I tried everything, even deleting columns and rebuilding them, which
eventually created a new error that fatally compromised the database
(if you're curious, and as an aside, it created this error: "'Authors'
table - Unable to modify table. Cannot insert the value NULL into
column 'AuthorID', able 'DCV3_CSharp.dbo.Tmp_Authors'; column does
not allow nulls. INSERT fails.
The statement has been terminated.")
One thing (that shouldn't matter, since it didn't matter when I used C+
+ rather than C#): the column in table "Author" is a primary key,
while it is a "foreign key" in table "Content". But that is
irrelevant when creating a relationship, no? Also the checkbox "Allow
Nulls" is checked "NO" for all columns. This did not matter when
successfully compiling /building the relationship when using C++, but
I wonder if perhaps C# is less forgiving, and maybe I should check
"YES" for allowing Nulls?
Very bizarre. If anybody has any advice please offer it. I think SQL
is a dinosaur language and should be scraped, and RDBMS are obsolete
in view of cheap memory, faster processors, and managed pointers, but
that's another matter.
Thanks.
RL
Navigation:
[Reply to this message]
|