Re: Coding at table with multiple primary key columns
From: ryan (ryan_at_discussions.microsoft.com)
Date: 02/15/05
- Next message: MikeBayneOBA: "Re: IF/THEN Syntax help needed....... Please assist"
- Previous message: DebbieG: "Re: IF/THEN Syntax help needed....... Please assist"
- In reply to: Andi Mayer: "Re: Coding at table with multiple primary key columns"
- Next in thread: ryan: "Re: Coding at table with multiple primary key columns"
- Reply: ryan: "Re: Coding at table with multiple primary key columns"
- Reply: Andi Mayer: "Re: Coding at table with multiple primary key columns"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Feb 2005 13:41:15 -0800
Hey Andi, this solution does not work I am getting a Constraint error. I am
using System.Data.OleDb. I dont know if that makes a difference. Also, will
the unique contraint do the same thing as the primary key. I dont think so.
All I need the key for is editing the table b/c if I dont have one and I try
to update the table I will get an error. Thanks
"Andi Mayer" wrote:
> On Tue, 15 Feb 2005 10:49:11 -0800, "ryan"
> <ryan@discussions.microsoft.com> wrote:
>
> >I am trying to create a talbe by coding in VB.Net and I know how to create a
> >table with one column as a primary key, but I need mulitple columns as the
> >key how can I do that? Right now I use:
> >SQL = "CREATE TABLE " & type & "_games_today ([Away] TEXT(20) CONSTRAINT
> >K_Away KEY, [Home] TEXT(20), [Away_Score] INTEGER, [Home_Score] INTEGER,
> >[Spread] SINGLE, [Home_Fav] BIT, [OverUnder] SINGLE, [Date] TEXT(20) , [Day]
> >TEXT(10), [Game] INTEGER)".
> >To make one column the PK, but if I add a second or thrid constraint as as
> >PK in the same way it does not work. Can someone help me?
>
> out of the help file: Topic Microsoft Jet SQL reference
>
> This example creates a new table called MyTable with two text fields,
> a Date/Time field, and a unique index made up of all three fields.
>
> Sub CreateTableX2()
> Dim dbs As Database
> ' Modify this line to include the path to Northwind
> ' on your computer.
> Set dbs = OpenDatabase("Northwind.mdb")
> ' Create a table with three fields and a unique
> ' index made up of all three fields.
>
> dbs.Execute "CREATE TABLE MyTable " _
> & "(FirstName CHAR, LastName CHAR, " _
> & "DateOfBirth DATETIME, " _
> & "CONSTRAINT MyTableConstraint UNIQUE " _
> & "(FirstName, LastName, DateOfBirth));"
> dbs.Close
>
> End Sub
>
> ---
> If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
> MW
>
- Next message: MikeBayneOBA: "Re: IF/THEN Syntax help needed....... Please assist"
- Previous message: DebbieG: "Re: IF/THEN Syntax help needed....... Please assist"
- In reply to: Andi Mayer: "Re: Coding at table with multiple primary key columns"
- Next in thread: ryan: "Re: Coding at table with multiple primary key columns"
- Reply: ryan: "Re: Coding at table with multiple primary key columns"
- Reply: Andi Mayer: "Re: Coding at table with multiple primary key columns"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|