Here are two SQL statements that will create table1 and then create table2 with PK, FK and inforced integrity. string _StrSQL; string tblName = "table1"; string tblName2 = "table2"; _StrSQL = @"CREATE TABLE " + tblName + @" (RecID AUTOINCREMENT " + @" CONSTRAINT PK_" + tblName + " PRIMARY KEY, " + @" RecorderID VARCHAR WITH COMPRESSION, " + @" GroupID VARCHAR WITH COMPRESSION, " + @" Name VARCHAR WITH COMPRESSION, " + @" Address VARCHAR WITH COMPRESSION)"; _StrSQL = @"CREATE TABLE " + tblName + @"(HourID AUTOINCREMENT" + @" CONSTRAINT PK_" + tblName + " PRIMARY KEY," + @" RecID INTEGER NOT NULL " + @" CONSTRAINT FK_" + tblName2 + "_" + tblName + @" REFERENCES " + tblName2 + " (RecID) " + @" ON UPDATE CASCADE " + @" ON DELETE CASCADE," + @" DSID INTEGER NOT NULL," + @" [Month] INTEGER," + @" [Day] INTEGER," + @" [Year] INTEGER," + @" [Hour] INTEGER)"; You do not have to use the '@' symboly. I use it because it make the statement easier on my eyes. Then drop the _StrSQL in a OleDbCommand: object _obj = null; OleDbConnection OleConn = new OleDbConnection(_ConnString); OleDbCommand OleComm = new OleDbCommand(_SQLString, OleConn); OleComm.Connection.Open(); _obj = OleComm.ExecuteScalar(); OleComm.Connection.Close(); Good Luck, Jason
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software. [^]