472,954 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

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 5945
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.