="Syntax error in INSERT INTO statement."someone please help

  • Thread starter Thread starter Bigwayner
  • Start date Start date
B

Bigwayner

Guest
ive have tried changing values to '" & textbox.text & "' and it actual puts in the "& textbox.text &" i n database field

still keep getting this error

System.Data.OleDb.OleDbException was unhandled by user code

ErrorCode=-2147217900

Message="Syntax error in INSERT INTO statement."

Source="Microsoft JET Database Engine"

StackTrace:

at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)

at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)

at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)

at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)

at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)

at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

at ASP.userpage_aspx.create_Click(Object sender, EventArgs e) in C:\Documents and Settings\Justin\My Documents\Visual Studio 2005\WebSites\WebSite2\UserPage.aspx:line 74

at System.Web.UI.WebControls.Button.OnClick(EventArgs e)

at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)




please help me i have to get this website up and running so i can graduate. any info would be helpful




Private Sub create_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim UserName As String = txtUserName.Text

Dim Password As String = txtPassword.Text

Dim cPassword As String = txtConfirmPassword.Text

Dim fName As String = txtContactFirstName.Text

Dim lName As String = txtContactLastName.Text

Dim cName As String = txtCompanyName.Text

Dim mail As String = txtEmail.Text

Dim ph As String = txtPhone.Text

Dim fax As String = txtFax.Text

Dim addr As String = txtAddress.Text

Dim city As String = txtCity.Text

Dim stat As String = txtState.Text

Dim zip As String = txtZip.Text

Dim valid As Boolean = False


Dim x As Integer = 0

Dim dataset As New Data.DataSet




If UserName = Nothing Then


MsgBox("Please Enter UserName")

valid = False


End If


If Password = Nothing Then


MsgBox("Please Enter a Password")

valid = False


End If



If fName = Nothing Then


MsgBox("Please Enter your first name")

valid = False


End If


If lName = Nothing Then


MsgBox("Please Enter your Last name")

valid = False


Else


valid = True


End If


If valid = True Then


Dim Cmd As System.Data.OleDb.OleDbCommand

Dim SQL As String


Dim objCmd As New System.Data.OleDb.OleDbCommand

Dim dataadapter = New System.Data.OleDb.OleDbDataAdapter


Dim con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Justin\Desktop\website icons\updateAFO_v3.3.mdb")

SQL = "INSERT INTO [Customers] (CompanyName, ContactFirstName, ContactLastName, Phone, Email, Fax, Address, City, State, Zip, UserName, Password) VALUES ( @CompanyNam,@ContactFirstNam,@ContactLastNam, @Phon, @Emai, @Fa, @Addres, @City @Stat, @Zi, @UserNam, @Passwor)"





Cmd = New System.Data.OleDb.OleDbCommand(SQL, con)



objCmd = New System.Data.OleDb.OleDbCommand(SQL, con)

objCmd.Parameters.Add("@CompanyNam", Data.OleDb.OleDbType.Char).Value = txtCompanyName.ToString

objCmd.Parameters.Add("@ContactFirstNam", Data.OleDb.OleDbType.Char).Value = txtContactFirstName.ToString

objCmd.Parameters.Add("@ContactLastNam", Data.OleDb.OleDbType.Char).Value = txtContactLastName.ToString

objCmd.Parameters.Add("@Phon", Data.OleDb.OleDbType.Char).Value = txtPhone.ToString

objCmd.Parameters.Add("@Emai", Data.OleDb.OleDbType.Char).Value = txtEmail.ToString

objCmd.Parameters.Add("@Fa", Data.OleDb.OleDbType.Char).Value = txtFax.ToString

objCmd.Parameters.Add("@Addres", Data.OleDb.OleDbType.Char).Value = txtAddress.ToString

objCmd.Parameters.Add("@Cit", Data.OleDb.OleDbType.Char).Value = txtCity.ToString

objCmd.Parameters.Add("@Stat", Data.OleDb.OleDbType.Char).Value = txtState.ToString

objCmd.Parameters.Add("@Zi", Data.OleDb.OleDbType.Char).Value = txtZip.ToString

objCmd.Parameters.Add("@UserNam", Data.OleDb.OleDbType.Char).Value = txtUserName.ToString

objCmd.Parameters.Add("@Passwor", Data.OleDb.OleDbType.Char).Value = txtPassword.ToString

con.Open()

objCmd.ExecuteNonQuery()


con.Close()



Continue reading...
 
Back
Top