English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

query = "INSERT INTO MembersInfo ("Name,User Name,Password,Confirm Password, Password hint, Address, City, Postal Code, State, Country, [Home No:],[Handphone No:], SMS Alerts, E-mail Address") VALUES (" & "'" & txtName.Text & "'" & "," & "'" & txtUserName.text & "'" & "," & "'" & txtPassword.text & "'" & "," & "'" & txtConfirmPassword.text & "'" & "," & "'" & txtPasswordHint.text & "'" & "," & "'" & txtAddress.text & "'" & "," & "'" & txtCity.text & "'" & "," & "'" & txtPostalCode.text & "'" & "," & "'" & txtState.text & "'" & "," & "'" & txtCountry.text & "'" & "," & "'" & txtHome.text & "'" & "," & "'" & txtHandphone.text & "'" & "," & "'" & txtEmail.text & "'" & ")"
error message: end of statement expected...where?HELP PLEASE

2006-08-02 04:38:35 · 6 answers · asked by braich_gal 3 in Computers & Internet Programming & Design

if possible please note the error or correct it

2006-08-02 04:46:53 · update #1

aarge and mainstrike: i tried what you guys said but all the txtName.text etc. are then underlined with the error name 'txt...' not declared

2006-08-02 05:33:39 · update #2

6 answers

There are a couple issues here.
- As someone pointed out, there are many quotes and it gets confusing.
- Field names with special characters in them require a binding around them to indicate the full field name.
- Without knowing the way your database is structured, this would be very challenging. For example, is your User Name field really User Name? If so, it must be quoted because of the space.

What I am doing below is removing some unnecessary quotes and adding square brackets to delimit the field name correctly.

query = "INSERT INTO MembersInfo ([Name],[User Name],[Password], [Confirm Password], [Password hint], [Address], [City], [Postal Code], [State], [Country], [Home No:], [Handphone No:], [SMS Alerts], [E-mail Address]) VALUES ('" & txtName.Text & "', '" & txtUserName.text & "', '" & txtPassword.text & "', '" & txtConfirmPassword.text & "', '" & txtPasswordHint.text & "', '" & txtAddress.text & "', '" & txtCity.text & "', '" & txtPostalCode.text & "', '" & txtState.text & "', '" & txtCountry.text & "', '" & txtHome.text & "', '" & txtHandphone.text & "', '" & txtEmail.text & "');"

Please modify your question to also include the structure of your table so that I can ensure accuracy of the query. All these modifications assume you are using Microsoft Access. They may not work under other SQL databases.

2006-08-02 05:05:11 · answer #1 · answered by mainstrike 2 · 2 1

try "INSERT INTO MembersInfo (Name,User Name,Password,Confirm Password, Password hint, Address, City, Postal Code, State, Country, [Home No:],[Handphone No:], SMS Alerts, E-mail Address) VALUES ('" & txtName.Text & "','" & txtUserName.Text & "','" & txtPassword.Text & "','" & txtConfirmPassword.Text & "','" & txtPasswordHint.Text & "','" & txtAddress.Text & "','" & txtCity.Text & "','" & txtPostalCode.Text & "','" & txtState.Text & "','" & txtCountry.Text & "','" & txtHome.Text & "','" & txtHandphone.Text & "','" & txtEmail.Text & "')"

2006-08-02 04:55:54 · answer #2 · answered by aargre 2 · 0 0

your commas look correct to me. You have the same amount of values to column names. Try putting a semi-colon at the end of the statement before you hit enter. ;

There could be other issues... hard to tell without having access to the database. Your entries look weird and your column names seem weird as well (the ones with the brackets). The error you're getting is most commonly referring to a missing semi-colon at the end of a statement.

2006-08-02 04:58:57 · answer #3 · answered by gpashtun 1 · 0 0

first off, there should be no quotes around your field names section (back tics ` around each one if you want, but not quotes around the whole section. EDIT - I didn't note the spaces in some of your field names, those you will definately need the back tics around.

Next you need to comma seperate each of the values being inserted into the fields in your VALUES(...) section

And use a different type of quote mark in the query than around the query. I.e. query="INSERT INTO table VALUES ('a','b')"; not query="INSERT INTO table VALUES ("a","b")"; the commas in the query are seen to be the end of the programming statement.

2006-08-02 05:09:43 · answer #4 · answered by John J 6 · 0 0

In your VALUES I see a bunch of "" "" without any commas separating them. You should make sure you separate each object youre trying to insert into that table.

And you dont need quotes after MembersInfo("
get rid of those quotation marks.

EDIT: If the .text is not declared that means it does not exist. Check your tables and make sure that the reference to that object exists or else it gets confused.

2006-08-02 04:43:29 · answer #5 · answered by Sean I.T ? 7 · 0 0

the string at first is not concatenated correctly and you Ar using Fields name that have special characters without the []

2006-08-02 04:53:23 · answer #6 · answered by Javy 2 · 0 0

fedest.com, questions and answers