hi guys,
I have these 3 tables
CREATE TABLE MUSICIANS
(SSN CHAR(10) NOT NULL WITH DEFAULT,
NAME CHAR(30) NOT NULL WITH DEFAULT,
PRIMARY KEY (SSN));
CREATE UNIQUE INDEX IXMUSICIANS ON MUSICIANS
(SSN);
CREATE TABLE INSTRUMENTS
(INSTRID CHAR(10) NOT NULL WITH DEFAULT,
DNAME CHAR(10) NOT NULL WITH DEFAULT,
KEY CHAR(05) NOT NULL WITH DEFAULT,
PRIMARY KEY (INSTRID));
CREATE UNIQUE INDEX IXINSTRUMENTS ON INSTRUMENTS
(INSTRID);
CREATE TABLE PLAYS
(SSN CHAR(10) NOT NULL WITH DEFAULT,
INSTRID CHAR(10) NOT NULL WITH DEFAULT,
PRIMARY KEY (SSN, INSTRID),
FOREING KEY (SSN) REFERENCES MUSICIANS,
FOREING KEY (INSTRID) REFERENCES INSTRUMENTS);
CREATE UNIQUE INDEX IXPLAYS ON PLAYS
(SSN,INSTRID);
I need vb code to ceate these 3 tables in one click.
I used this code to create one table but I'm getting error with it.
cmd = New SqlCommand()
cmd.Connection = conn
' cmd.CommandText = _
'"CREATE TABLE MUSICIANS" & "(SSN CHAR(10) NOT NULL WITH DEFAULT," & "NAME CHAR(30) NOT NULL WITH DEFAULT," & "PRIMARY KEY (SSN));" & "CREATE UNIQUE INDEX IXMUSICIANS ON MUSICIANS" & "(SSN);"
cmd.ExecuteNonQuery()
the error was "Error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'with'"
waiting for your help guys.
thank you
Eyla.
I have these 3 tables
CREATE TABLE MUSICIANS
(SSN CHAR(10) NOT NULL WITH DEFAULT,
NAME CHAR(30) NOT NULL WITH DEFAULT,
PRIMARY KEY (SSN));
CREATE UNIQUE INDEX IXMUSICIANS ON MUSICIANS
(SSN);
CREATE TABLE INSTRUMENTS
(INSTRID CHAR(10) NOT NULL WITH DEFAULT,
DNAME CHAR(10) NOT NULL WITH DEFAULT,
KEY CHAR(05) NOT NULL WITH DEFAULT,
PRIMARY KEY (INSTRID));
CREATE UNIQUE INDEX IXINSTRUMENTS ON INSTRUMENTS
(INSTRID);
CREATE TABLE PLAYS
(SSN CHAR(10) NOT NULL WITH DEFAULT,
INSTRID CHAR(10) NOT NULL WITH DEFAULT,
PRIMARY KEY (SSN, INSTRID),
FOREING KEY (SSN) REFERENCES MUSICIANS,
FOREING KEY (INSTRID) REFERENCES INSTRUMENTS);
CREATE UNIQUE INDEX IXPLAYS ON PLAYS
(SSN,INSTRID);
I need vb code to ceate these 3 tables in one click.
I used this code to create one table but I'm getting error with it.
cmd = New SqlCommand()
cmd.Connection = conn
' cmd.CommandText = _
'"CREATE TABLE MUSICIANS" & "(SSN CHAR(10) NOT NULL WITH DEFAULT," & "NAME CHAR(30) NOT NULL WITH DEFAULT," & "PRIMARY KEY (SSN));" & "CREATE UNIQUE INDEX IXMUSICIANS ON MUSICIANS" & "(SSN);"
cmd.ExecuteNonQuery()
the error was "Error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'with'"
waiting for your help guys.
thank you
Eyla.