Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi, im new to programming so pleaser bear with me :)

 

Im trying to make a program that creates a table for every entry on a table(store) and inherits (store sample). But it has error. Can somebody please point out to me what im doing wrong.......

 

       Dim cmdstr As String = ""
       Dim rdstr As String = ""
       rdstr = "SELECT store FROM stores"
       con1.Open()
       con2.Open()
       Dim cmdread As New OleDbCommand(rdstr, con2)
       Dim objreader As OleDbDataReader = cmdread.ExecuteReader()
       Dim cmdmke As New OleDbCommand(cmdstr, con1)

       Do While objreader.Read()
           objreader.Read()
           cmdstr = "CREATE TABLE [" + objreader("store") + "] INHERITS [store sample]"
           Label1.Text = objreader("store")
           cmdmke.ExecuteNonQuery()  <<<<<<<<<<< ERROR!!!
       Loop
       con1.Close()
       con2.Close()

Edited by PlausiblyDamp
  • Administrators
Posted

What error does it give? Also try the following

Dim cmdstr As String = ""
Dim rdstr As String = ""
rdstr = "SELECT store FROM stores"
con1.Open()
con2.Open()
Dim cmdread As New OleDbCommand(rdstr, con2)
Dim objreader As OleDbDataReader = cmdread.ExecuteReader()
Dim cmdmke As OleDbCommand

Do While objreader.Read()
   objreader.Read()
   cmdstr = "CREATE TABLE [" + objreader("store") + "] INHERITS [store sample]"
   cmdmke = New OleDbCommand(cmdstr, con1)
   Label1.Text = objreader("store")
   cmdmke.ExecuteNonQuery()  <<<<<<<<<<< ERROR!!!
Loop
con1.Close()
con2.Close() 

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I think my SQL statement is the problem. Can you please give me an example statement that creates a table then copies the content of another table. Dont know if i need to use

INHERITS os CREATE TABLE AS. Proper syntax so that i could use it with vb.net please...........:)

 

EX. "CREATE TABLE qwerty INHERITS yuiop" (which i know is wrong since it gives an error)

Posted

You can use Select * into New_Table from Old_Table

 

Like this you will create automatically a new table with the same structure and the same data. However i don't think that it will keep the indexes, so check it out

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...