473,652 Members | 3,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Incorrect syntax near the keyword 'where'

109 New Member
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 3407
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
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 New Member
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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?r eport=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 Recognized Expert Contributor
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
ioabastillas
1 New Member
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 Recognized Expert Contributor
This is one more good point.
Do not use Sql Keywords like

Id
Description
Date
Like
Where
Name
group
….
…..
….
Etc…,
Nov 21 '07 #10

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

Similar topics

1
14180
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) as Declare @sid int, @fad_a2 int,
11
7098
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 syntax near the keyword 'DEFAULT'" The form has 2 fields on it, called tb_username and tb_password. (see code snippet below).
2
10825
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'. Please help, I am learning SQL Server. thanks in advance. Ismail use mis select CLAIM_DETAILS_HCVW.INTEREST, CLAIM_DETAILS_HCVW.NET, CLAIM_HMASTERS_VS.
0
1889
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, director.dreceived_director" _ & " FROM director INNER JOIN disabappl ON director.applno = disabappl.applno INNER JOIN " _ & " district ON disabappl.submitted_dist = district.dist_cd INNER JOIN" _ &...
3
28884
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). There are 3 possibilities in the hra_data table that will cause the loctable to be updated with the calculated value. After playing with it, I thought it was in the correct format but I keep getting an "Incorrect syntax..." error. Any guidence would be...
0
8304
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 records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
1
3353
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 ROW_NUMBER() OVER (ORDER BY BaseTours.DateCreated DESC) AS RowNumber
3
15839
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 6 Incorrect syntax near the keyword 'AS'. Any help so much appreciated with as(
1
6245
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. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'user'. Source Error: Line 35: MyAdapter1 = new SqlDataAdapter(MyCommand1); Line 36: MyDataSet1 = new DataSet(); Line 37: ...
0
8367
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.