473,387 Members | 1,760 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,387 software developers and data experts.

Sysntax Error

Hello All!

I'm coding my UPDATE button on my data grid. Getting a syntax error, can't
seen to find it. Hope you can help
Thanks!!!

Rudy

Public Sub grdProducts_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
grdProducts.UpdateCommand

Dim Sqlconnection1 As New SqlConnection(SQL_CONNECTION_STRING)
Dim cmdProd As SqlCommand
Dim txtProductName As String = e.Item.Cells(1).Text
Dim txtSupplier As String = e.Item.Cells(2).Text
Dim txtCost As String = e.Item.Cells(4).Text
Dim txtSRP As String = e.Item.Cells(5).Text
Dim txtInStock As String = e.Item.Cells(3).Text
Dim strUpdate As String

strUpdate = "UPDATE IMSProducts SET " & _
"ProductName = ' " & txtProductName & " ', " & _
"Supplier = ' " & txtSupplier & " ', " & _
"Cost = ' " & txtCost & " ', " & _
"SRP = ' " & txtSRP & " ', " & _
"InStock = ' " & txtInStock & " ', " & _
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"

Sqlconnection1 = New
SqlConnection(ConfigurationSettings.AppSettings("C onnString"))
cmdProd = New SqlCommand(strUpdate, Sqlconnection1)
SqlConnection1.Open()
cmdProd.ExecuteNonQuery()

grdProducts.EditItemIndex = -1
BindProductsGrid()


End Sub
Nov 19 '05 #1
3 1077
Sorry, I forgot to tell you where the error is, it's on this line
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"
Thanks Again!!

"Rudy" wrote:
Hello All!

I'm coding my UPDATE button on my data grid. Getting a syntax error, can't
seen to find it. Hope you can help
Thanks!!!

Rudy

Public Sub grdProducts_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
grdProducts.UpdateCommand

Dim Sqlconnection1 As New SqlConnection(SQL_CONNECTION_STRING)
Dim cmdProd As SqlCommand
Dim txtProductName As String = e.Item.Cells(1).Text
Dim txtSupplier As String = e.Item.Cells(2).Text
Dim txtCost As String = e.Item.Cells(4).Text
Dim txtSRP As String = e.Item.Cells(5).Text
Dim txtInStock As String = e.Item.Cells(3).Text
Dim strUpdate As String

strUpdate = "UPDATE IMSProducts SET " & _
"ProductName = ' " & txtProductName & " ', " & _
"Supplier = ' " & txtSupplier & " ', " & _
"Cost = ' " & txtCost & " ', " & _
"SRP = ' " & txtSRP & " ', " & _
"InStock = ' " & txtInStock & " ', " & _
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"

Sqlconnection1 = New
SqlConnection(ConfigurationSettings.AppSettings("C onnString"))
cmdProd = New SqlCommand(strUpdate, Sqlconnection1)
SqlConnection1.Open()
cmdProd.ExecuteNonQuery()

grdProducts.EditItemIndex = -1
BindProductsGrid()


End Sub

Nov 19 '05 #2
Rudy,

You may be getting error bcoz u r using ProductID = ' " instead of ""
(double quotation marks)...

"Rudy" wrote:
Sorry, I forgot to tell you where the error is, it's on this line
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"
Thanks Again!!

"Rudy" wrote:
Hello All!

I'm coding my UPDATE button on my data grid. Getting a syntax error, can't
seen to find it. Hope you can help
Thanks!!!

Rudy

Public Sub grdProducts_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
grdProducts.UpdateCommand

Dim Sqlconnection1 As New SqlConnection(SQL_CONNECTION_STRING)
Dim cmdProd As SqlCommand
Dim txtProductName As String = e.Item.Cells(1).Text
Dim txtSupplier As String = e.Item.Cells(2).Text
Dim txtCost As String = e.Item.Cells(4).Text
Dim txtSRP As String = e.Item.Cells(5).Text
Dim txtInStock As String = e.Item.Cells(3).Text
Dim strUpdate As String

strUpdate = "UPDATE IMSProducts SET " & _
"ProductName = ' " & txtProductName & " ', " & _
"Supplier = ' " & txtSupplier & " ', " & _
"Cost = ' " & txtCost & " ', " & _
"SRP = ' " & txtSRP & " ', " & _
"InStock = ' " & txtInStock & " ', " & _
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"

Sqlconnection1 = New
SqlConnection(ConfigurationSettings.AppSettings("C onnString"))
cmdProd = New SqlCommand(strUpdate, Sqlconnection1)
SqlConnection1.Open()
cmdProd.ExecuteNonQuery()

grdProducts.EditItemIndex = -1
BindProductsGrid()


End Sub

Nov 19 '05 #3
You have a comma before the WHERE statement.

"InStock = ' " & txtInStock & " ', " & _
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"

Shawn

"Rudy" <Ru**@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
Sorry, I forgot to tell you where the error is, it's on this line
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"
Thanks Again!!

"Rudy" wrote:
Hello All!

I'm coding my UPDATE button on my data grid. Getting a syntax error, can't seen to find it. Hope you can help
Thanks!!!

Rudy

Public Sub grdProducts_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
grdProducts.UpdateCommand

Dim Sqlconnection1 As New SqlConnection(SQL_CONNECTION_STRING)
Dim cmdProd As SqlCommand
Dim txtProductName As String = e.Item.Cells(1).Text
Dim txtSupplier As String = e.Item.Cells(2).Text
Dim txtCost As String = e.Item.Cells(4).Text
Dim txtSRP As String = e.Item.Cells(5).Text
Dim txtInStock As String = e.Item.Cells(3).Text
Dim strUpdate As String

strUpdate = "UPDATE IMSProducts SET " & _
"ProductName = ' " & txtProductName & " ', " & _
"Supplier = ' " & txtSupplier & " ', " & _
"Cost = ' " & txtCost & " ', " & _
"SRP = ' " & txtSRP & " ', " & _
"InStock = ' " & txtInStock & " ', " & _
"WHERE ProductID = ' " & e.Item.Cells(0).Text & " '"

Sqlconnection1 = New
SqlConnection(ConfigurationSettings.AppSettings("C onnString"))
cmdProd = New SqlCommand(strUpdate, Sqlconnection1)
SqlConnection1.Open()
cmdProd.ExecuteNonQuery()

grdProducts.EditItemIndex = -1
BindProductsGrid()


End Sub

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: nu b | last post by:
Hello all. I am new and I am having a tough time spotting my error here. The idea is to produce an applet that will have a JButton which I can push to display the string myName. Later I will make...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
1
by: nkosinathi | last post by:
Hi Guys im trying to write an import class where i can import information from .CSV file into my database. I am getting the following error Errors: You have an error in your SQL syntax. Check the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...

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.