locked
Why do I get this message???!! (SQL)

    Question

  •  

    I´m trying to add a table and fields to a access file whit sql...

     

    here is the code

     

    Code Block

    Try

    con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Databas\Access\Lesni\Lesni_Datalogg.mdb"

    con.Open()

     

    da = New OleDb.OleDbDataAdapter(sql, con)

    da.Fill(ds, "Database")

    con.Close()

     

    Catch ex As Exception

    MsgBox(ex.Message)

    con.Close()

    End Try

     

    sql = "Create Table Factory (LogDt DATETIME unique, Plant1 Char, Plant2 Char, Plant3 Char, Plant4 Char, Plant5 Char, Plant6 Char, Plant7 Char, Plant8 Char, Plant9 Char, Plant10 Char)"

     

    But I get the ex.message "Post is to big" (I get the ex message in swedish so not 100% of the translation)???

     

    But if i try to have this as sql string =  "Create Table Factory (LogDt DATETIME unique, Plant1 Char, Plant2 Char, Plant3 Char, Plant4 Char, Plant5 Char)" it works great??

     

    what sould I do?? I need to add many fields to the table...

     

    Regards

     

    //edmund

    Sunday, January 20, 2008 10:25 AM

Answers

  • Hi edmund again Wink

     

    I think your problem is with the "Char". This seems to be no Access-Datatype. Second I don't understand why you use a dataadapter and a dataset for this, because it just a simple sql command.

    This worked for me:

     

    Code Block

    ' define new db connection

    Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\suranda\Visual Studio Projects\testSolution\testDB.mdb")

    Dim cmd As New OleDb.OleDbCommand("Create Table Factory (LogDt DATETIME unique, Plant1 Text(1), Plant2 Text(1), Plant3 Text(1), Plant4 Text(1), Plant5 Text(1), Plant6 Text(1), Plant7 Text(1), Plant8 Text(1), Plant9 Text(1), Plant10 Text(1))", con)

    con.Open()

    cmd.ExecuteNonQuery()

    con.Close()

     

     

    Monday, January 21, 2008 10:55 AM

All replies

  • Hi edmund again Wink

     

    I think your problem is with the "Char". This seems to be no Access-Datatype. Second I don't understand why you use a dataadapter and a dataset for this, because it just a simple sql command.

    This worked for me:

     

    Code Block

    ' define new db connection

    Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\suranda\Visual Studio Projects\testSolution\testDB.mdb")

    Dim cmd As New OleDb.OleDbCommand("Create Table Factory (LogDt DATETIME unique, Plant1 Text(1), Plant2 Text(1), Plant3 Text(1), Plant4 Text(1), Plant5 Text(1), Plant6 Text(1), Plant7 Text(1), Plant8 Text(1), Plant9 Text(1), Plant10 Text(1))", con)

    con.Open()

    cmd.ExecuteNonQuery()

    con.Close()

     

     

    Monday, January 21, 2008 10:55 AM
  • Hi Mate!

     

    Thank you so! What would i do without you?!

     

    Yepp changed it to a NoQuery now and it works great!

     

    Thanks again!

     

    Monday, January 21, 2008 11:29 AM
  • you were lucky, I still has the piece of code from last time saved on my computer, so it was not too much work this time Wink

     

    Monday, January 21, 2008 12:01 PM
  • hehe sweet

     

    Monday, January 21, 2008 1:57 PM
  • hey mate... could you maybe just mark the post above as answer to the question... I am always filtering open issues without really looking at the subjects and that makes me click this thread every now and then Wink

     

    Tuesday, January 22, 2008 11:16 AM