I am new to the programming world. Can someone please help me. I keep getting error during a INSERT statement.
Error Msg
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.
Below is my code... Please assist.
<%@ Page Language="
VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
' Insert page code here
'
Dim myConnection as OleDbConnection
Dim strConnectionString as String = "Provider=Microsoft.Jet.OleDB.4.0;Data Source = C:\Documents and Settings\slalani\Desktop\pubs.mdb"
Sub Page_Load(send As System.Object, e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
GetConnection()
End If
End Sub
sub AddUser(ByVal sender as System.Object, ByVal e as System.EventArgs)
dim intRecordAffected as Integer
GetConnection()
Dim strSql as String = "INSERT INTO users([username],[password]) values('" & _
uname.Text & "','" & _
password.Text & "')"
Dim myCommand as New OleDbCommand(strSQL, myConnection)
''Dim txtRecAff
''Dim intRecordAffected
''intRecordAffected = myCommand.ExecuteNonQuery()
''txtRecAff = intRecordsAffected & " record added successfully."
ClearForm()
End Sub
sub GetConnection()
myConnection = New OleDbConnection(strConnectionString)
myConnection.Open
End Sub
Sub ClearForm()
uname.Text = ""
password.Text = ""
End Sub
Sub addBtn_Click(sender As Object, e As EventArgs)
''AddUser(ByVal sender as System.Object, ByVal e as System.EventArgs)
dim intRecordAffected as Integer
GetConnection()
Dim strSql as String = "INSERT INTO users(username,password) values('" & _
uname.Text & "','" & _
password.Text & "')"
Dim myCommand as New OleDbCommand(strSQL, myConnection)
''Dim txtRecAff
''Dim intRecordAffected
intRecordAffected = myCommand.ExecuteNonQuery()
''txtRecAff = intRecordsAffected & " record added successfully."
ClearForm()
End Sub
evol77