Re: Syntax error in INSERT INTO statement.
From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 04/02/04
- Next message: Stan Sainte-Rose: "Re: Syntax error in INSERT INTO statement."
- Previous message: Jasima DJ: "Syntax error in INSERT INTO statement."
- In reply to: Jasima DJ: "Syntax error in INSERT INTO statement."
- Next in thread: Stan Sainte-Rose: "Re: Syntax error in INSERT INTO statement."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 2 Apr 2004 11:16:00 -0800
It looks like you're trying to concatenate fields together. This should be
done using an & operator instead of a "+" operator . However, this is not a
good idea. I suggest you use a Command and a Parameters collection to
execute this INSERT. This will eliminate a number of potential issues (one
of which you might have already encountered). More importantly, it will help
prevent SQL injection attacks.
Unfortunately, you're using OleDb which means you can't simply turn on the
Profiler and see what's getting sent to the server for processing.
In any case I also suggest you add a Try/Catch block to the code to trap the
exceptions--this way you can tell what's really going on.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Jasima DJ" <dakiddgal@hotmail.com> wrote in message
news:%23IvgkVOGEHA.3080@tk2msftngp13.phx.gbl...
> I wrote the following code for my submit button...
>
> Private Sub tb_submit_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles tb_submit.Click
> Dim strSQL As String = _
> "INSERT INTO Members
> (userId,password,verify,email,country,addess) VALUES('" + tb_userId.Text
> + "', '" + tb_password.Text + "', '" + tb_verify.Text + "', '" +
> tb_email.Text + "', '" + tb_country.Text + "', '" + tb_address.Text +
> "')"
> OleDbConnection1.Open()
> Dim cmd As New OleDbCommand(strSQL, OleDbConnection1)
> cmd.ExecuteNonQuery()
> OleDbConnection1.Close()
> End Sub
> ===========================================================
>
> But i keep getting the following error.....I cant seem to fix...can you
> elp me fix it? plzzz....
>
> 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 53: OleDbConnection1.Open()
> Line 54: Dim cmd As New OleDbCommand(strSQL, OleDbConnection1)
> Line 55: cmd.ExecuteNonQuery()
> Line 56: OleDbConnection1.Close()
> Line 57: End Sub
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
- Next message: Stan Sainte-Rose: "Re: Syntax error in INSERT INTO statement."
- Previous message: Jasima DJ: "Syntax error in INSERT INTO statement."
- In reply to: Jasima DJ: "Syntax error in INSERT INTO statement."
- Next in thread: Stan Sainte-Rose: "Re: Syntax error in INSERT INTO statement."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|