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 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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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
|
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....
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |