Sysntax Error

G

Guest

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("ConnString"))
cmdProd = New SqlCommand(strUpdate, Sqlconnection1)
SqlConnection1.Open()
cmdProd.ExecuteNonQuery()

grdProducts.EditItemIndex = -1
BindProductsGrid()




End Sub
 
G

Guest

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

Guest

Rudy,

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

Shawn

You have a comma before the WHERE statement.

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

Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top