473,804 Members | 3,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Incorrect Syntax near WHERE

19 New Member
Hi Guys, new to development using visual studio and vb.net 2.0. and SQL express. Have a small problem.

I have an update command which im using to change the values of a blob image table to NULL so that i can then insert a new image into the table. This works fine. My problem is that my insert statement has an error and i cant figure this out. if i dont add the where clause it works fine but inserts the new image into the table without the product data, i want to insert the new image into the existing product information.

Expand|Select|Wrap|Line Numbers
  1.  <asp:SqlDataSource ID="productsUpdate" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringAccountType %>"
  2.                      SelectCommand="SELECT [ProductID], [ProductName], [ImageTitle], [ImageData], [ImageMimeType] FROM [Products] WHERE [ProductID] = @ProductID"
  3.                      UpdateCommand="UPDATE [Products] SET [ImageTitle] = Null, [ImageData] = Null, [ImageMimeType] = Null WHERE [ProductID] = @ProductID" InsertCommand="INSERT INTO [Products] ([ImageTitle], [ImageData], [ImageMimeType]) VALUES (@ImageTitle, @ImageData, @MimeType) WHERE ([ProductID] = @ProductID)">
  4.                     <SelectParameters>
  5.                         <asp:ControlParameter ControlID="GridView1" Name="ProductID" PropertyName="SelectedValue"
  6.                             Type="Int32" />
  7.                     </SelectParameters>
  8.                     <UpdateParameters>
  9.                         <asp:Parameter Name="ImageTitle" />
  10.                         <asp:Parameter Name="ImageData" Type="string" />
  11.                         <asp:Parameter Name="MimeType" Type="string" />
  12.                     </UpdateParameters>
  13.                     <InsertParameters>
  14.                         <asp:Parameter Name="ImageTitle" Type="String" />
  15.                         <asp:Parameter Name="ImageData" />
  16.                         <asp:Parameter Name="MimeType" Type="String" />
  17.                     </InsertParameters>
  18.                 </asp:SqlDataSource>
The error message i keep getting is "incorrect syntax near where"

Any help would be greatly appreciated
Thanks
May 12 '07 #1
3 3403
Vidhura
99 New Member
you cannot use Where statement in insert statement
May 14 '07 #2
Vidhura
99 New Member
you cannot use Where clause in insert statement
May 14 '07 #3
teddymeu
19 New Member
you cannot use Where clause in insert statement
Ok let me rephrase this as a question. I have a table in my database called products, it holds th product information for example, price, size description. It also holds an image of the product. The site admin might want to update this image at some point. I tried creating a datagrid which showed all products from the product table without the image. I then used a select statement to pull the selected product details into a datagrid which had a databound text box for the image title, and file upload control to select the image. I used the same function as i had used before to upload the image in the first place. I created what i thought would be the correct update statement but kept recieveing a message saying, cannot convert varbinary max to varchar.

Any ideas?
May 15 '07 #4

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

Similar topics

4
9928
by: Carl | last post by:
Can you tell me what is wrong with this syntax ? string select = "UPDATE .. " + "(,,,,,,, ,,,, ,,, , , , ) " + " VALUES (@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
1
11255
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." Explaining you the scene is the following Stored Proc.
1
2358
by: iporter | last post by:
In the following code, the two Response.Write statements output exactly the same - I can copy and paste both into Query Analyzer, and run them fine. However, if I comment out line 3, the assignment of "SELECT T..." to the variable query, the last line produces the error: Line 1: Incorrect syntax near '<'. Many thanks in advance for any explanation - the problem is tearing my hair out!! Iain
5
4262
by: Mario Krsnic | last post by:
Hallo zusammen, I have an app. with SQL-Server. The same page worked fine with Access-DB. Now I have a problem with this command: Dim strSQL As String Dim myConnection As New SqlConnection("server=mssql07.1und1.de;uid=dbo88888888;pwd=8888888;database=db88888888") myConnection.Open()
3
28932
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
8334
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
3362
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
10
3429
by: arial | last post by:
Hi, I am getting this error message: Incorrect syntax near the keyword 'where'. 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 'where'. Source Error:
1
6271
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
9706
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
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10320
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
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
9150
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
7620
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
5521
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
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.