Hi.
This is killing me. I am trying to insert a row into an Access table, but
it's giving me an exception as below.
"Syntax error in INSERT INTO statement."
When I debug and look at the SQL string it is as follows.
"insert into tblCustomer (PropertyType, FirstName, LastName, Address1,
Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone,
Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las
Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')"
If I copy the above statement in SQL View, it is fine. I just don't get it.
The below is my code.
private int InsertCustomer(OleDbConnection oConn)
{
string sSQL = "insert into tblCustomer (PropertyType, FirstName,
LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone,
MobilePhone, OtherPhone, Email, Password) values (" +
Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" +
Session["LastName"] + "', '" + Session["Address1"] + "', '" +
Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] +
"', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" +
Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" +
Session["OtherPhone"] + "', '" + Session["Email"] + "', '" +
Session["Password"] + "')";
OleDbCommand oCmd = new OleDbCommand(sSQL, oConn);
oCmd.ExecuteNonQuery();
Your input is appreciated.
J
--
Be Cool! 5 1495
Hi BeCool,
Although you will see probably all messages about SQL server injections,
which has of course nothing to do with your access database, is this normal
way to go (it is not the recordset way from ADODB). http://msdn.microsoft.com/library/de...eterstopic.asp
I hope this helps,
Cor
Hi,
I think this is because of some datatype mismatch. The front end and
backend databases may not be mapped correctly.
Just a thought!
Thanks,
Dinesh
"Cor Ligthert" wrote: Hi BeCool,
Although you will see probably all messages about SQL server injections, which has of course nothing to do with your access database, is this normal way to go (it is not the recordset way from ADODB).
http://msdn.microsoft.com/library/de...eterstopic.asp
I hope this helps,
Cor
On Wed, 11 May 2005 18:30:02 -0700, thejackofall <th**********@discussions.microsoft.com> wrote:
¤ Hi.
¤
¤ This is killing me. I am trying to insert a row into an Access table, but
¤ it's giving me an exception as below.
¤
¤ "Syntax error in INSERT INTO statement."
¤
¤ When I debug and look at the SQL string it is as follows.
¤
¤ "insert into tblCustomer (PropertyType, FirstName, LastName, Address1,
¤ Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone,
¤ Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las
¤ Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')"
¤
¤ If I copy the above statement in SQL View, it is fine. I just don't get it.
¤ The below is my code.
¤
¤ private int InsertCustomer(OleDbConnection oConn)
¤ {
¤ string sSQL = "insert into tblCustomer (PropertyType, FirstName,
¤ LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone,
¤ MobilePhone, OtherPhone, Email, Password) values (" +
¤ Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" +
¤ Session["LastName"] + "', '" + Session["Address1"] + "', '" +
¤ Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] +
¤ "', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" +
¤ Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" +
¤ Session["OtherPhone"] + "', '" + Session["Email"] + "', '" +
¤ Session["Password"] + "')";
¤ OleDbCommand oCmd = new OleDbCommand(sSQL, oConn);
¤ oCmd.ExecuteNonQuery();
¤
¤ Your input is appreciated.
¤ J
The column name Password is a reserved word. You will need to either enclose it within brackets or
rename it within your SQL statement.
Paul
~~~~
Microsoft MVP (Visual Basic)
Hi,
I meant front end and backend datatypes. (not databases)
Sorry for that...
Dinesh
"thejackofall" wrote: Hi.
This is killing me. I am trying to insert a row into an Access table, but it's giving me an exception as below.
"Syntax error in INSERT INTO statement."
When I debug and look at the SQL string it is as follows.
"insert into tblCustomer (PropertyType, FirstName, LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone, Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')"
If I copy the above statement in SQL View, it is fine. I just don't get it. The below is my code.
private int InsertCustomer(OleDbConnection oConn) { string sSQL = "insert into tblCustomer (PropertyType, FirstName, LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone, Email, Password) values (" + Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" + Session["LastName"] + "', '" + Session["Address1"] + "', '" + Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] + "', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" + Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" + Session["OtherPhone"] + "', '" + Session["Email"] + "', '" + Session["Password"] + "')"; OleDbCommand oCmd = new OleDbCommand(sSQL, oConn); oCmd.ExecuteNonQuery();
Your input is appreciated. J
-- Be Cool!
Thanks.
J
--
Be Cool!
"Paul Clement" wrote: On Wed, 11 May 2005 18:30:02 -0700, thejackofall <th**********@discussions.microsoft.com> wrote:
¤ Hi. ¤ ¤ This is killing me. I am trying to insert a row into an Access table, but ¤ it's giving me an exception as below. ¤ ¤ "Syntax error in INSERT INTO statement." ¤ ¤ When I debug and look at the SQL string it is as follows. ¤ ¤ "insert into tblCustomer (PropertyType, FirstName, LastName, Address1, ¤ Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone, ¤ Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las ¤ Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')" ¤ ¤ If I copy the above statement in SQL View, it is fine. I just don't get it. ¤ The below is my code. ¤ ¤ private int InsertCustomer(OleDbConnection oConn) ¤ { ¤ string sSQL = "insert into tblCustomer (PropertyType, FirstName, ¤ LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone, ¤ MobilePhone, OtherPhone, Email, Password) values (" + ¤ Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" + ¤ Session["LastName"] + "', '" + Session["Address1"] + "', '" + ¤ Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] + ¤ "', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" + ¤ Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" + ¤ Session["OtherPhone"] + "', '" + Session["Email"] + "', '" + ¤ Session["Password"] + "')"; ¤ OleDbCommand oCmd = new OleDbCommand(sSQL, oConn); ¤ oCmd.ExecuteNonQuery(); ¤ ¤ Your input is appreciated. ¤ J
The column name Password is a reserved word. You will need to either enclose it within brackets or rename it within your SQL statement.
Paul ~~~~ Microsoft MVP (Visual Basic) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ImraneA |
last post by:
Hi there
I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K.
Wish to provide some knowledge gained back to community - hopefully
help others.
1.Question how do you test stored...
|
by: Bri |
last post by:
Greetings,
I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record...
|
by: crypto_solid via AccessMonster.com |
last post by:
I have been using a SQL database with a VB5 frontend for about 5 years.
Works well. Unfortunately I don't have access to the source code.
I was tasked with implementing a "job entry" application...
|
by: Abareblue |
last post by:
I have no clue on how to insert a record into access. here is the whole
thing
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
|
by: geodev |
last post by:
I’m copying data across from an Access database to an MSDE database through
the use of some vb.net code.
Unfortunately the application crashes when it goes to copy across data, in
particular...
|
by: Geoffrey KRETZ |
last post by:
Hello,
I'm wondering if the following behaviour is the correct one for
PostGreSQL (7.4 on UNIX).
I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching
the following request :...
|
by: MP |
last post by:
Hi
Posted this several hours ago to another ng but it never showed up thought
i'd try here.
using vb6, ado, .mdb, jet4.0, no access
given table tblJob with field JobNumber text(10)
'The...
|
by: Mike Charney |
last post by:
I have a two part question:
First I want to insert data into a table and I am using the following
command:
INSERT INTO tblmain
SELECT field1, field2, etc...
FROM tblimport
WHERE ??????
The...
|
by: etuncer |
last post by:
Hello All,
I have Access 2003, and am trying to build a database for my small
company. I want to be able to create a word document based on the data
entered through a form. the real question is...
|
by: lenygold via DBMonster.com |
last post by:
Hi everybody:
What is the best way to
I have 10 tables with similar INSERT requiremnts.
INSERT INTO ACSB.VAATAFAE
WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS
( SELECT AA_TIN,...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
| |