Results 1 to 2 of 2

Thread: Can anyone assist with the Adding Records Issue.[Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    90

    Can anyone assist with the Adding Records Issue.[Resolved]

    I am tying to add a datarow to an access database.
    Here is the code
    Try
    InvoiceConnection = New OleDb.OleDbConnection
    InvoiceConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\InvoiceData.mdb"

    UserCommand = New OleDb.OleDbCommand(sSQLString)
    UserAdapter = New OleDb.OleDbDataAdapter(UserCommand)
    UserCommand.Connection = InvoiceConnection
    InvoiceConnection.Open()
    UserCommand.ExecuteNonQuery()

    UserAdapter.FillSchema(dsUser, SchemaType.Source)
    UserAdapter.Fill(dsUser, "UserInfo")

    Try
    Dim autonumber As Short = 0
    Dim drUserRow as New Datarow
    drUserRow = dsUser.Tables("UserInfo").NewRow()
    drUserRow.Item(0) = autonumber
    drUserRow.Item(1) = txtUserName.Text
    drUserRow.Item(2) = txtPassword.Text
    drUserRow.Item(3) = txtFullName.Text
    drUserRow.Item(4) = txtAddress1.Text
    drUserRow.Item(5) = txtAddress2.Text
    drUserRow.Item(6) = txtCity.Text
    drUserRow.Item(7) = cboState.Text
    drUserRow.Item(8) = txtZipCode.Text
    drUserRow.Item(9) = txtPhoneNumber.Text
    Dim userbuilder As New OleDb.OleDbCommandBuilder(UserAdapter)
    UserAdapter = userbuilder.DataAdapter
    dsUser.Tables("UserInfo").Rows.Add(drUserRow)
    UserAdapter.Update(dsUser, "UserInfo")
    Catch ex As Exception
    Call MessageBox.Show(ex.Message & " Occured In: " & ex.Source, "Error Adding Record", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
    InvoiceConnection.Close()


    I am getting an error message on The Line:
    UserAdapter.Update(dsUser, "UserInfo")
    It says "Syntax Error in INSERT INTO Statement"

    I am not sure why this is not working. I have pretty much gone by Pirate's Example.

    It adds to the dataset fine. Just will not add it to the table.

    any help would be appreciated
    Thanks in Advance
    Last edited by OUSoonerFan; Aug 30th, 2003 at 11:08 PM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    90
    I have resolved my issue. Sorry to waste the post. One of my filed names in my database had a space in it....lol....

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