473,224 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Incorrect syntax near the keyword 'where'

109 100+
Hi,
I am getting this error message:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Incorrect syntax near the keyword 'where'. 
  3. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  4.  
  5. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'where'.
  6.  
  7. Source Error: 
  8.  
  9.  
  10. Line 51: Qcheckdata.SelectCommand.CommandText = "where [id] = '9102806883277882981'";
  11. Line 52: 
  12. Line 53:     Qcheckdata.Fill(dsQuick1);
  13. Line 54: 
  14. Line 55: 
  15.  
  16.  
  17. Source File: d:\devsite\tap\checkoutform\qcheck.aspx.cs    Line: 53 
  18.  
  19. Stack Trace: 
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  

and this is what I have in my code.

Expand|Select|Wrap|Line Numbers
  1. Qcheckdata.SelectCommand.CommandText = "where [id] = '9102806883277882981'";
  2.  
  3. Qcheckdata.Fill(dsQuick1);
  4.  
  5.  
  6.  

can any one help me please?

I don't know why I am getting this error message.

Thank You,
Nov 19 '07 #1
10 3363
Shashi Sadasivan
1,435 Expert 1GB
for starters.
a sql command is generally of the format
Expand|Select|Wrap|Line Numbers
  1. select fieldName from table
a where clause is put after the sql statement.
Expand|Select|Wrap|Line Numbers
  1. select fieldName from table where [id] = 1234567
1. I dont see any select query...and the database has no source to select table, fields.

2. is id a varchar field or a numeric field?
if it is a numeric field , get rid of the single quotes around the number as that will throw an error. single quotes define strings.
Nov 20 '07 #2
arial
109 100+
Thanks Shashi.

That helped.

but I did not do that way because I had my database and table mapped to the sqldataadpter so i thought i don't need to specify that.


Thank You,
Nov 20 '07 #3
arial
109 100+
Oh got into another problem.

I change my query string to:
Expand|Select|Wrap|Line Numbers
  1. string getqis = str.ToString();
  2. Qcheckdata.SelectCommand.CommandText = " select * from  Pass_Insp where [id] = 'getqid'";
  3.  
it doesn't give me any result and don't know why?

Thanks,
Nov 20 '07 #4
Shashi Sadasivan
1,435 Expert 1GB
Oh got into another problem.

I change my query string to:
Expand|Select|Wrap|Line Numbers
  1. string getqis = str.ToString();
  2. Qcheckdata.SelectCommand.CommandText = " select * from  Pass_Insp where [id] = 'getqid'";
  3.  
it doesn't give me any result and don't know why?

Thanks,
did you want to do this?
Expand|Select|Wrap|Line Numbers
  1. string getqis = str.ToString();
  2. Qcheckdata.SelectCommand.CommandText = " select * from  Pass_Insp where [id] = '"+getqis+"'";
  3.  
Nov 20 '07 #5
arial
109 100+
Thanks a million Shashi.

Also, if you know something on this.

What I need now is to send my ID to another project to pull up a different report.

both my project is under same root direcotry and are .net website.

Root: 1) Proj1
2) Proj2
how can i accomplish this?

Any help would be appreciated.
Nov 20 '07 #6
Shashi Sadasivan
1,435 Expert 1GB
You may either refrence project 1 in project2 and use the same session class being shared.
Or you could sent the request as a query string as in http://yourwebsite.com/yourpage.aspx?report=ppp
where pp is the query param value.

but i am not sure if the security will have to be compromised for this
Nov 20 '07 #7
CyberSoftHari
487 Expert 256MB
Good practice is you have to use LIKE keyword for string in where clause.
(I think this should be move to Sqlserver form!)
Nov 20 '07 #8
Hi,
I am getting this error message:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Incorrect syntax near the keyword 'where'. 
  3. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  4.  
  5. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'where'.
  6.  
  7. Source Error: 
  8.  
  9.  
  10. Line 51: Qcheckdata.SelectCommand.CommandText = "where [id] = '9102806883277882981'";
  11. Line 52: 
  12. Line 53:     Qcheckdata.Fill(dsQuick1);
  13. Line 54: 
  14. Line 55: 
  15.  
  16.  
  17. Source File: d:\devsite\tap\checkoutform\qcheck.aspx.cs    Line: 53 
  18.  
  19. Stack Trace: 
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  

and this is what I have in my code.

Expand|Select|Wrap|Line Numbers
  1. Qcheckdata.SelectCommand.CommandText = "where [id] = '9102806883277882981'";
  2.  
  3. Qcheckdata.Fill(dsQuick1);
  4.  
  5.  
  6.  

can any one help me please?

I don't know why I am getting this error message.

Thank You,
'----------------------------------------------------------
hello :-)

try to complete your statement..... are you using select statement?

or change you field name, instead of id, try different name like EmpID for employee ID...

hope this can help with your problem....

:-)
Nov 21 '07 #9
CyberSoftHari
487 Expert 256MB
This is one more good point.
Do not use Sql Keywords like

Id
Description
Date
Like
Where
Name
group
….
…..
….
Etc…,
Nov 21 '07 #10
arial
109 100+
Thank you so much all for your suggestion.
Nov 29 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jeff Magouirk | last post by:
Dear Group, I am trying to create a view and keep getting the Incorrect syntax near the keyword 'Declare'" error. Here is the code I am writing. Create view fixed_airs (sid, fad_a2, fad_a3)...
11
by: Mark Findlay | last post by:
Hello Experts! I am attempting to use the OleDbCommand.ExecuteScaler() function within my ASP.NET C# web page to perform a simple validation, but receive the following error: "Incorrect...
2
by: ielmrani via SQLMonster.com | last post by:
Hi Everyone, I really tried to not post this question but I gave up. I tried brackets, parenth...etc but nothing worked. I get this error message: Incorrect syntax near the keyword 'THEN'. ...
0
by: netone | last post by:
I am developing site using dot NET.... when I use this sql query Dim mydata As String = "SELECT director.applno, district.distName, disabappl.recvddate_sdo, disabappissue.IDCardNo,...
3
by: wallic | last post by:
Hello, This is my first post and I am a beginner with SQL code. The code below is supposed to update a new table (loctable) with a calculated value based on the original table (hra_data). ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
1
by: itamar82 | last post by:
I am getting the following error: Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near the keyword 'WHERE'. for the sql below: SELECT TourId FROM (SELECT...
3
by: Skillman | last post by:
Hi Everybody, I'm beginer in SQL and was wonder if anybody could take a look at this and help me. I got this error, and not sure how to fix it. This is the error: Msg 156, Level 15, State 1, Line...
1
by: karenkksh | last post by:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. ...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.