469,917 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Incorrect Syntax near WHERE

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 3164
Vidhura
99
you cannot use Where statement in insert statement
May 14 '07 #2
Vidhura
99
you cannot use Where clause in insert statement
May 14 '07 #3
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

Post your reply

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

Similar topics

4 posts views Thread by Carl | last post: by
1 post views Thread by Sandesh | last post: by
1 post views Thread by iporter | last post: by
5 posts views Thread by Mario Krsnic | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.