Help with erroe

thelner

Member
Joined
Sep 11, 2006
Messages
6
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.......

Code:
        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()
 
Last edited by a moderator:
What error does it give? Also try the following
Code:
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()
 
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)
 
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 dont think that it will keep the indexes, so check it out
 
Back
Top