Results 1 to 11 of 11

Thread: [RESOLVED]Insert Command not updating

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    [RESOLVED]Insert Command not updating

    Hi,

    I am doing my first Web.Application and I have connected to a database and from the webform the user will input his details to be stored in the first available row and update it. I have this procedure


    VB Code:
    1. Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click
    2.         MyConn.Open()
    3.        Dim sql As String = "Select * FROM ApplicantsDetails"
    4.         Dim mydataadapter As New OleDbDataAdapter
    5.         mydataadapter = New OleDbDataAdapter(Sql, MyConn)
    6.         Dim mycmdbuilder As New OleDbCommandBuilder(mydataadapter)
    7.         Dim myDatatable As New DataTable
    8.         mydataadapter.Fill(myDatatable)
    9.         Dim mynewrow As DataRow = myDatatable.NewRow
    10.         mynewrow(0) = TxtID.Text
    11.         mynewrow(1) = TxtName.Text
    12.         mynewrow(2) = Txtsurname.Text
    13.         mynewrow(6) = dropdschool.SelectedValue.ToString
    14.         myDatatable.Rows.Add(mynewrow)
    15.         mydataadapter.Update(myDatatable)
    16.         MyConn.Close()
    17.     End Sub

    and it is giving me an error:

    HTML Code:
    Syntax error in INSERT INTO statement. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
    
    Source Error: 
    
    
    Line 97:         mynewrow(6) = dropdschool.SelectedValue.ToString
    Line 98:         myDatatable.Rows.Add(mynewrow)
    Line 99:         mydataadapter.Update(myDatatable)
    Line 100:        MyConn.Close()
    Line 101:    End Sub
    Can someone please tell me where I am missing... thanks
    Last edited by angelica; Oct 6th, 2005 at 04:08 AM.

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