Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...