rickb
Member
Heres what Ive got : I have a button which, when clicked, needs to create a new table in an existing database. The name of the new table comes from a label text property, which gets its value from a combobox selection. Heres the code where my problem exists:
Dim oledbcon as New oledb.oledbconnection=("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= <path to db>")
oledbcon.open
Dim oledbcom as New oledb.oledbcommand=("CREATE TABLE" & lblinstructor.text & "(Col1 Text, <plus more columns>)",oledbcon)
Debug.WriteLine(oledbcom.ExecuteNonQuery())
The error shows up at the last line ("Debug. . . ).
This works perfectly if the table name is a static name, but thats not what I need.
Can someone show me, or point me in the right direction, for creating a new table whos name is dynamic? Thanks in advance.
Dim oledbcon as New oledb.oledbconnection=("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= <path to db>")
oledbcon.open
Dim oledbcom as New oledb.oledbcommand=("CREATE TABLE" & lblinstructor.text & "(Col1 Text, <plus more columns>)",oledbcon)
Debug.WriteLine(oledbcom.ExecuteNonQuery())
The error shows up at the last line ("Debug. . . ).
This works perfectly if the table name is a static name, but thats not what I need.
Can someone show me, or point me in the right direction, for creating a new table whos name is dynamic? Thanks in advance.