473,651 Members | 3,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

INSERT INTO...(passwor d) syntax error


Hi! I am currently creating a Registration form which contained: UserID
Password, FirstName and LastName.

These details would be inserted into Ms Access when I click submi
button. But I encounter with the problem to insert 'Password'. It work
fine if I did not insert 'Password' but if I did, it will shows that
have "syntax error: INSERT INTO..."

Did I miss something to write? Please kindly have a look on the cod
below, Thank you!

<%@ Import Namespace="Syst em.Data" %>

<%@ Imports Namespace="Syst em.Data.OleDb" %>

Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e A
System.EventArg s) Handles btnSubmit.Click

Dim InsertCmd As New OleDbCommand

Dim SQLInsert As String

Dim DBConn As OleDbConnection

Dim Connstr As String

Connstr = "Provider=Micro soft.jet.oledb. 4.0;" & _

"DAT
SOURCE=C:\Inetp ub\wwwroot\samp les\Project\bin \Project-Library.mdb"

SQLInsert = "INSERT INTO User_Profile (UserID, Password, FirstName
LastName) VALUES ('" & txtUserID.Text & "', '" & txtRegPwd.Text & "'
'" & txtFirstName.Te xt & "', '" & txtLastName.Tex t & "')"

'Create connection

DBConn = New OleDbConnection (Connstr)

InsertCmd.Conne ction = DBConn

InsertCmd.Comma ndText = SQLInsert

Try

DBConn.Open()

InsertCmd.Execu teNonQuery()

Catch ex As Exception

Response.Write( ex.ToString())

Finally

DBConn.Close()

End Try

End Su

--
jinhy82Posted from http://www.pcreview.co.uk/ newsgroup acces

Nov 19 '05 #1
3 1623
hi,
use [password] instead of password in the insert statement since password is
a reserved keyword.
--
The best
srini
http://www.expertszone.com
"jinhy82" wrote:

Hi! I am currently creating a Registration form which contained: UserID,
Password, FirstName and LastName.

These details would be inserted into Ms Access when I click submit
button. But I encounter with the problem to insert 'Password'. It works
fine if I did not insert 'Password' but if I did, it will shows that I
have "syntax error: INSERT INTO..."

Did I miss something to write? Please kindly have a look on the code
below, Thank you!

<%@ Import Namespace="Syst em.Data" %>

<%@ Imports Namespace="Syst em.Data.OleDb" %>

Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click

Dim InsertCmd As New OleDbCommand

Dim SQLInsert As String

Dim DBConn As OleDbConnection

Dim Connstr As String

Connstr = "Provider=Micro soft.jet.oledb. 4.0;" & _

"DATA
SOURCE=C:\Inetp ub\wwwroot\samp les\Project\bin \Project-Library.mdb"

SQLInsert = "INSERT INTO User_Profile (UserID, Password, FirstName,
LastName) VALUES ('" & txtUserID.Text & "', '" & txtRegPwd.Text & "',
'" & txtFirstName.Te xt & "', '" & txtLastName.Tex t & "')"

'Create connection

DBConn = New OleDbConnection (Connstr)

InsertCmd.Conne ction = DBConn

InsertCmd.Comma ndText = SQLInsert

Try

DBConn.Open()

InsertCmd.Execu teNonQuery()

Catch ex As Exception

Response.Write( ex.ToString())

Finally

DBConn.Close()

End Try

End Sub
--
jinhy82Posted from http://www.pcreview.co.uk/ newsgroup access

Nov 19 '05 #2

It's not good to use string concatenation in SQL commands. The better way is
to use parameters...
http://samples.gotdotnet.com/quickst...teCommand.aspx

Are you sure that there is no error in field name 'Password'? Maybe you have
a typos in database table?

"jinhy82" <jinhy82.1q7a2y @> wrote in message
news:oc******** ************@gi ganews.com...

Hi! I am currently creating a Registration form which contained: UserID,
Password, FirstName and LastName.

These details would be inserted into Ms Access when I click submit
button. But I encounter with the problem to insert 'Password'. It works
fine if I did not insert 'Password' but if I did, it will shows that I
have "syntax error: INSERT INTO..."

Did I miss something to write? Please kindly have a look on the code
below, Thank you!

<%@ Import Namespace="Syst em.Data" %>

<%@ Imports Namespace="Syst em.Data.OleDb" %>

Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click

Dim InsertCmd As New OleDbCommand

Dim SQLInsert As String

Dim DBConn As OleDbConnection

Dim Connstr As String

Connstr = "Provider=Micro soft.jet.oledb. 4.0;" & _

"DATA
SOURCE=C:\Inetp ub\wwwroot\samp les\Project\bin \Project-Library.mdb"

SQLInsert = "INSERT INTO User_Profile (UserID, Password, FirstName,
LastName) VALUES ('" & txtUserID.Text & "', '" & txtRegPwd.Text & "',
'" & txtFirstName.Te xt & "', '" & txtLastName.Tex t & "')"

'Create connection

DBConn = New OleDbConnection (Connstr)

InsertCmd.Conne ction = DBConn

InsertCmd.Comma ndText = SQLInsert

Try

DBConn.Open()

InsertCmd.Execu teNonQuery()

Catch ex As Exception

Response.Write( ex.ToString())

Finally

DBConn.Close()

End Try

End Sub
--
jinhy82Posted from http://www.pcreview.co.uk/ newsgroup access

Nov 19 '05 #3
jinhy82 wrote:
Hi! I am currently creating a Registration form which contained:
UserID, Password, FirstName and LastName.

These details would be inserted into Ms Access when I click submit
button. But I encounter with the problem to insert 'Password'. It
works fine if I did not insert 'Password' but if I did, it will
shows that I have "syntax error: INSERT INTO..."

Did I miss something to write? Please kindly have a look on the code
below, Thank you!

<%@ Import Namespace="Syst em.Data" %>

<%@ Imports Namespace="Syst em.Data.OleDb" %>

Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click

Dim InsertCmd As New OleDbCommand

Dim SQLInsert As String

Dim DBConn As OleDbConnection

Dim Connstr As String

Connstr = "Provider=Micro soft.jet.oledb. 4.0;" & _

"DATA
SOURCE=C:\Inetp ub\wwwroot\samp les\Project\bin \Project-Library.mdb"

SQLInsert = "INSERT INTO User_Profile (UserID, Password, FirstName,
LastName) VALUES ('" & txtUserID.Text & "', '" & txtRegPwd.Text & "',
'" & txtFirstName.Te xt & "', '" & txtLastName.Tex t & "')"

What if a mr O'Brian wants to register?? Your sql will crash!

Look up: sql injection attack
and start looking into parameters.

Hans Kesting
'Create connection

DBConn = New OleDbConnection (Connstr)

InsertCmd.Conne ction = DBConn

InsertCmd.Comma ndText = SQLInsert

Try

DBConn.Open()

InsertCmd.Execu teNonQuery()

Catch ex As Exception

Response.Write( ex.ToString())

Finally

DBConn.Close()

End Try

End Sub

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2812
by: Neil Zanella | last post by:
Hello, I am trying to execute ADO.NET INSERT statement where one of the fields is coming from a password HTML control. When I access the text with password.Value and print with Response.Write so as to check that it is working correctly it displays just fine. However, whenever I include the password field in one of the SQL INSERT statement's fields I get the following error:
3
2489
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
1
5398
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. And the line it shows in red is cmd.ExecuteNonQuery()
6
3449
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.