473,467 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with SQL "INSERT INTO " syntax

Good day,
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.

My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:

INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')

This structure comes from http://www.w3schools.com/sql/sql_insert.asp

Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?

Evan

Jun 20 '07 #1
6 5979
Try
INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661',@ 'H:\CommConn\userdata\a.xml')

Notice the @ sign. "\" is an escape character. You have to use 2 '\'s if you
dont use the @ sign.

HTH

<ew******@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
Good day,
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.

My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:

INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')

This structure comes from http://www.w3schools.com/sql/sql_insert.asp

Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?

Evan

Jun 20 '07 #2
I was using Visual Basic, and did not believe that to be the problem.
I tried anyway, used the @ symbol. That didn't work, so I tried using
'\\' instead. Finally, I removed the last field altogether and had
just:

INSERT INTO LoginInfo (username, password) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661')

and the query still failed.

I'm totally lost now.

Evan

On Jun 20, 4:27 pm, "Srini" <ls_re...@hotmail.comwrote:
Try
INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661',@ 'H:\CommConn\userdata\a.xml')

Notice the @ sign. "\" is an escape character. You have to use 2 '\'s if you
dont use the @ sign.

HTH

<ewpat...@gmail.comwrote in message

news:11**********************@g4g2000hsf.googlegro ups.com...
Good day,
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.
My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:
INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')
This structure comes fromhttp://www.w3schools.com/sql/sql_insert.asp
Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?
Evan

Jun 21 '07 #3
Good day,
>
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.

My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:

INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')

This structure comes from http://www.w3schools.com/sql/sql_insert.asp

Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?

Evan
How are you executing this? C# or VB don't know anything about SQL commands.
You will have to use some sort of SqlCommand to send this sql-statement
to the database.

If this is not the problem, show some more code about how you are trying
to use it.

Hans Kesting
Jun 21 '07 #4
On Jun 20, 4:12 pm, ewpat...@gmail.com wrote:
Good day,

I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.

My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:

INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')

This structure comes fromhttp://www.w3schools.com/sql/sql_insert.asp

Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?
A few things. First, are you building the insert string? If so, are
you positive it's building the way you think it is?

Always try the sql statement in query analyzer to see if your SQL
statement is valid, or if you're building a poor SQL statement.

Jun 22 '07 #5
On Jun 21, 4:58 am, ewpat...@gmail.com wrote:
I was using Visual Basic, and did not believe that to be the problem.
I tried anyway, used the @ symbol. That didn't work, so I tried using
'\\' instead. Finally, I removed the last field altogether and had
just:

INSERT INTO LoginInfo (username, password) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661')

and the query still failed.

I'm totally lost now.
What error are you getting? Have you tried putting username and/or
password into [square brackets] in case they are reserved words? Is
the username field large enough for the size of the data you're trying
to put into it? Is there any validation on the database which is
rejecting your data for violating constraints, primary key etc?

Jun 22 '07 #6
It looks to me like it may be a data type exception, if the second column is
of SQL type uniqueidentifier, which is the same thing as a guid. The format
looks similar to the uniqueidentifier binary format, which would not have
single quotes around it. A uniqueidentifier value in a query should only
have single quotes around it when it is in the string format
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Larry Bud" <la**********@yahoo.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...
On Jun 20, 4:12 pm, ewpat...@gmail.com wrote:
>Good day,

I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into it has been troublesome to
say the least.

My ASP.NET script is supposed to execute an INSERT INTO statement in
order to add a user to the database. Here is a sample:

INSERT INTO LoginInfo (username, password, datafile) VALUES ('a',
'0cc175b9c0f1b6a831c399e269772661', 'H:\CommConn\userdata\a.xml')

This structure comes fromhttp://www.w3schools.com/sql/sql_insert.asp

Everything seems valid, but ASP still throws an error stating that the
syntax of the statement is invalid. Could someone point out where the
'syntax' error is?

A few things. First, are you building the insert string? If so, are
you positive it's building the way you think it is?

Always try the sql statement in query analyzer to see if your SQL
statement is valid, or if you're building a poor SQL statement.

Jun 25 '07 #7

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

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
0
by: newbie_mw | last post by:
Hi Ian, Thanks for help! The columns and variables are exactly matched so it shouldn't be the problem. Actually the original html and php files are pretty long. But I guess a more detailed...
1
by: newbie_mw | last post by:
Seems my post was buried in more cries for help :-) I will try again. It's probably a very novice question so please take a look! Thanks!...
4
by: lawrence | last post by:
Google can't find me a good example of how to use the "if exists" syntax in MySql. Is it right that to use it this way: INSERT INTO IF EXISTS tMyTable VALUES("xxlk", "lkjlkjlkjljk") I want...
9
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction...
2
by: CFW | last post by:
I use the following flawlessly to insert a single field: strSQL = "Insert into (Casket) Values " _ & "(" & conQuote & NewCasket & conQuote & ")" Set db = CurrentDb If MsgBox(NewCasket & " is...
4
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone...
3
by: shifty shaker | last post by:
I've modified sql text and now i'm getting a syntax error that I cannot figure out....anyone? error occurs at the Insert Into line but the entire function is given in case you need it. ---...
3
by: david | last post by:
I have following code, but I do not know where the problem is. Thank you for any help. David ----Code--- 'connection conn = New SqlConnection _ ("data source=localhost;integrated...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...

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.