Forum Moderators: open
If Page.IsValid() Then
Dim sPath As String = "connection_string"
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=" & sPath & ";"
Dim objConnInsert As OleDbConnection
Dim cmdInsert As OleDbCommand
Dim strInsert As String = ""
lblStatus.Visible = False
'Open connection
objConnInsert = New OleDbConnection(connString)
objConnInsert.Open()
'Create SQL statement
If (chkAvailability.Checked = True) Then
strInsert = "INSERT INTO tblJobListing (position, availability) VALUES ('" & txtPosition.Text & "', True)"
Else
strInsert = "INSERT INTO tblJobListing (position, availability) VALUES ('" & txtPosition.Text & "', False)"
End If
'Execute query
cmdInsert = New OleDbCommand(strInsert.ToString(), objConnInsert)
cmdInsert.ExecuteNonQuery()
objConnInsert.Close()
Response.Redirect("ManageJobList.aspx")
End If
User ID=Admin;Password=
I tried and the insert using your code but my connection string and it worked. Another thing to try is with YES/NO fields you can use Yes and No as data, not just True/False.
Tom
I hope this is what you meant...
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=" & sPath & "; User ID=Admin; Password="
I also played around with YES/NO and TRUE/FALSE and I still get "Syntax error in INSERT INTO statement"
I understand what it's saying but I don't know how to fix it. When I display my INSERT statement, copy it, and try the SQL statement directly with the ISP's DB Manager, I don't get a syntax error and it works just fine. This confuses me completely. Can anyone help me out?