RE: Multiple primary keys with ADOX under C#

From: jk (jk_at_discussions.microsoft.com)
Date: 03/22/05


Date: Mon, 21 Mar 2005 17:09:01 -0800

Hi Oliver,
Did the answer to your post help you out ?
This is regarding to creation of multiple columns in primary key
It workd out for me but when i try to execute select statement
from code, it says not a valid book mark !
if u have solutin to this pls let me know

"Oliver Japes" wrote:

> Hello,
>
> can anyone provide me a sample where a new table is created with multiple
> columns in the primary key using ADOX under C#?
>
> Currently, I'm using this line to add the primary keys:
> currentTable.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
> currentColumn.Name, "", "");
>
> First thing is: all samples I can find say that the two empty strings at
> the end (for foreign key constraints) are optional, but I do only have one
> method, no overloads, so I have to call it this way.
>
> It works great for tables that only have one column in the primary key, but
> when I'm trying to add a second column, I'm getting a HRESULT: 0x80040E99,
> which I found out to be "The provider could not drop the object".
>
> Now I'm really confused on how to do that.
>
> I'm getting this ADOX-Exception all the time, no matter what I do, and all
> I can find are samples for Visual Basic. Is the whole world only coding VB
> now!?
>
> It would be great if someone could provide me one or more samples in C#.
>
> Thanks in advance,
>
>
> Oliver
>



Relevant Pages

  • Re: Inserting a new PK into an existing table
    ... could be desirable to have an additional primary key column because: ... The "old" primary key is composed of multiple columns (whose ... other tables via foreign keys. ... update statement that references the rownum for each row in the table. ...
    (comp.databases.oracle.misc)
  • Re: Composite primary key Question
    ... creating primary key on a multiple columns. ... CONSTRAINT PRIMARY KEY CLUSTERED ... To exeute these scripts you could use Execute method of ADO connection ...
    (microsoft.public.data.ado)
  • Re: Get Primary Key column
    ... No, and a primary key can also be a composite of multiple columns, so that ... What is it you're trying to accomplish? ... > Is there a way in SQL to reference the Primary Key column without using ...
    (microsoft.public.sqlserver.programming)