Hi all I am getting this error message while try to insert data using my .net webform. - Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '1'.
-
-
Source Error:
-
-
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
-
-
Stack Trace:
-
-
-
[SqlException: Line 1: Incorrect syntax near '1'.]
-
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +180
-
QualityQI.WebForm1.btnadd_Click(Object sender, EventArgs e) +1756
-
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
-
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
-
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
-
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
-
System.Web.UI.Page.ProcessRequestMain() +1292
-
-
-
I'll appreciate all yours help.
Thank You,
and my insert command is: -
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = sqlConnection1;
-
cmd.Connection.Open();
-
cmd.CommandText = "insert into gingercqi (QI_TRACK,DATE_RCV,INC_NUM,INC_DATE,INC_TIME,QANUM,BASE_HSP,ISSUE_IDENTIFY,MICN_INVOLVED,1ST_RESP1,1ST_RESP2,TRANSPORT1,INVESTIGATE,DATE_ASSIGN,CNE,DATE_CNE,INVPARTY1,INVPARTY2,INVPARTY3,INVPARTY4,OTHERINV,ISSUECATEGORY,ISSUEMEMO,QILEVEL,PACREPORTABLE,PACOUTCOME,CLOSEDATE,RES_CATEGORY,RES_MEMO,DISCIPLINE,DISC_TYPE,MD_REVIEW,POLICY_VIOLATION) VALUES ('"+txtqitrack.Text+"','"+Datercv.SelectedDate+"','"+ txtincnum.Text+"','"+ Dateinc.SelectedDate+"','"+txtinctime.Text+"','"+txtqanum.Text+"','"+dpbasehsp.SelectedValue+"','"+dpissueidentify.SelectedValue+"','"+txtmicninvl.Text+"','"+txt1stresp1.Text+"','"+txt1stresp2.Text+"','"+txttransport1.Text+"','"+dpinvestigate.SelectedValue+"','"+Dateasn.SelectedDate+"','"+dpcne.SelectedValue+"','"+Datecne.SelectedDate+"','"+dpinvlparty1.SelectedValue+"','"+dpinvlparty2.SelectedValue+"','"+dpinvlparty3.SelectedValue+"','"+dpinvlparty4.SelectedValue+"','"+txtotherinvl.Text+"','"+dpissuecate.SelectedValue+"','"+txtissuememo.Text+"','"+dpqilevel.SelectedValue+"','"+chkpacreport.Checked+"','"+txtpacoutcome.Text+"','"+Dateclose.SelectedDate+"','"+dpreslcate.SelectedValue+"','"+txtresolutionmemo.Text+"','"+chkdiscipline.Checked+"','"+txtdisctype.Text+"','"+chkmdreview.Checked+"','"+chkpolicyvio.Checked+"')";
-
cmd.ExecuteNonQuery();
-
cmd.Connection.Close();
-
6 1123
Hi arial,
As a good gesture, could you please run the program in debug mode, place a break point at where the commandtext is being created, and get the actaul text generated there.
Will help out debugging that.
It seems to be a syntax error with the sql statement
edit: Could you replace "1ST_RESP1,1ST_RESP2" in the field names to
[1ST_RESP1],[1ST_RESP2]
the square brackets lets sql know that it is a field name (field names generally do not start with number, or contain spaces, but the square brackets skips these constraints)
Thank Shashi.
You have been a great help.
The error I am getting while inserting checkbox value.
Which I am inserting like '"+chkmdreview.checked+"'.
Is it a correct way to insert check box value?
Thank You,
you will have to explicityly convert the checked value to zero or one.
With the above way, it will be converted to "true" or "false", while what you need to do it convert it to 0 or 1
actually that is what I need to insert in database like true or false so, in database "T " for true and "F" for false.
how can I accomplish this?
Thank You,
If you represent true and false using a varchar 'T' or 'F'
then use if statements !!!!
Thank You Shashi for you help.
So, this is what I did.
My datafield in database is char(1).
I put in my code. -
string md="";
-
-
if(chkpolicyvio.checked)
-
md = "T";
-
-
else
-
md = "F";
-
insert into table (policyvio) values ('"+Convert.ToChar(md)+"')
-
this gives me error message.
Error converting data type varchar to numeric.
Please help me.
Thank You,
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alban Hertroys |
last post by:
Hello,
I'm using psycopg to insert records in a number of threads. After the
threads finish, another thread runs to collect the inserted data. Now,
my problem is that psycopg let's my threads...
|
by: middletree |
last post by:
Posted this to Access group, meant to do it here:
I have what I call a composite table. Can't recall what they called it in
database class, but it's where you take the PK of two different...
|
by: David A. Caballero J. |
last post by:
I have a 3 layer system, SQL Server 2000 database, COM+ dll's (VC++ 6) and
ASP frontend, this system has been in production for quite some time using
english, spanish and portuguese versions. Now...
|
by: altergothen |
last post by:
Hi there
I am a newbie to ASP.Net - Please Help!
I am trying to insert the values of my variables into a database.
If I try the following it works perfectly:
string insertQuery = "INSERT into...
|
by: pramod |
last post by:
Hi
I am facing the problem while inserting the spanish characters in the
DB2 UDB v8.2 database. We are pulling the data from SQL server through
informatica and then pushing the same in the DB2...
|
by: Godzilla |
last post by:
Dear all,
I cannot find a solution for my problem with inserting a blob object
(>4000 in length) into an ORACLE database via ODBC.
I have tried the two ways of inserting the blob object (a...
|
by: Surya |
last post by:
Dear All,
I have problem on inserting a record to database..Although it looked
easy.. i have caught up with following issue .. please go ahead and
help me to find solution
I Need to insert...
|
by: boss1 |
last post by:
Hi all,
i m having a problem with inserting data in oracle db.
When i use form action =(call self page) then data is inserting properly.But problem with when using form...
|
by: len |
last post by:
Hi All
I have started a little pet project to learn python and MySQL. The
project involves figuring out all the combinations for a 5 number
lottery and storing the data in a MySQL file.
The...
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: 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,...
|
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...
|
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: 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...
| |