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:
Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click MyConn.Open() Dim sql As String = "Select * FROM ApplicantsDetails" Dim mydataadapter As New OleDbDataAdapter mydataadapter = New OleDbDataAdapter(Sql, MyConn) Dim mycmdbuilder As New OleDbCommandBuilder(mydataadapter) Dim myDatatable As New DataTable mydataadapter.Fill(myDatatable) Dim mynewrow As DataRow = myDatatable.NewRow mynewrow(0) = TxtID.Text mynewrow(1) = TxtName.Text mynewrow(2) = Txtsurname.Text mynewrow(6) = dropdschool.SelectedValue.ToString myDatatable.Rows.Add(mynewrow) mydataadapter.Update(myDatatable) MyConn.Close() End Sub
and it is giving me an error:
Can someone please tell me where I am missing... thanksHTML 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




Reply With Quote