rickb Posted February 7, 2003 Posted February 7, 2003 Here's what I've 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. Here's 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 that's not what I need. Can someone show me, or point me in the right direction, for creating a new table who's name is dynamic? Thanks in advance. Quote
*Experts* Nerseus Posted February 7, 2003 *Experts* Posted February 7, 2003 You need a space between TABLE and the name of the table. Right now, the double quote is next to the word TABLE. Try this instead: Dim oledbcom as New oledb.oledbcommand=("CREATE TABLE " & lblinstructor.text &... -Ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
rickb Posted February 7, 2003 Author Posted February 7, 2003 Thank you very much for the reply; it worked perfectly! You have saved my sanity. Quote
bungpeng Posted February 13, 2003 Posted February 13, 2003 Is it possible to create/delete Database in VB.NET? or any other way to do it? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.