Results 1 to 13 of 13

Thread: who is wrong me or ADO ? {Sorted }

Threaded View

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Unhappy who is wrong me or ADO ? {Sorted }

    I am using this code to save info written in textboxes to db .Everything seem to be fine but I don't know why it keeps throwing error saying "error in insert syntax "
    the error happens while reaching update line.
    Help plz
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, _
    2.  ByVal e As System.EventArgs) Handles Button1.Click
    3.  
    4.         Dim MySQLStr As String = "Select * From MyTab"
    5.         Dim Mypath As String = Application.StartupPath & "\webdb.mdb"
    6.         Dim MyCon As New OleDbConnection _
    7. ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Mypath)
    8.         Dim myadap As New OleDb.OleDbDataAdapter(MySQLStr, MyCon)
    9.         Dim objCmdBld As New OleDb.OleDbCommandBuilder(myadap)
    10.         Dim ds As DataSet = New DataSet()
    11.         MyCon.Open()
    12.  
    13.         myadap.Fill(ds, "mytab")
    14.         Dim MyDataRow As DataRow = ds.Tables("mytab").NewRow
    15.  
    16.         MyDataRow("URL") = Trim(TextBox1.Text)
    17.         MyDataRow("Category") = Trim(TextBox2.Text)
    18.         MyDataRow("Language") = Trim(TextBox3.Text)
    19.         MyDataRow("UserName") = Trim(TextBox4.Text)
    20.         MyDataRow("Password") = Trim(TextBox5.Text)
    21.         MyDataRow("Comment") = Trim(TextBox6.Text)
    22.         MyDataRow("last") = Trim(TextBox7.Text)
    23.  
    24.         ds.Tables("MyTab").Rows.Add(MyDataRow)
    25.         Try
    26.             myadap.Update(ds, "mytab")
    27.         Catch x As Exception
    28.             MsgBox(x.Message)
    29.         End Try
    30.         MyCon.Close()
    31.     End Sub
    Last edited by Pirate; Jan 18th, 2003 at 08:15 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width