tks for yoour help... i am trying to make an app to update the database from asp.net.. i get this error: Server Error in '/InTouchDataGrid' Application. -------------------------------------------------------------------------------- Syntax error in UPDATE
statement. 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.OleDb.OleDbException:
Syntax error in UPDATE statement. Source Error: Line 80: Try Line 81: conn.Open() Line 82: cmd.ExecuteNonQuery() Line 83: _gd1.EditItemIndex = -1 Line 84: Finally Source File: c:\inetpub\wwwroot\InTouchDataGrid\WebForm1.aspx.vb Line: 82 ----------------------------------------------------------------------------------------------------------
i have no idea how to get rid of this error or what is causing this error... can u pls help???i have been stuck on this like forever... this is my code :
Public Sub gd1_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Dim updateCmd As String
Dim conn As OleDbConnection
Dim contract As Boolean
updateCmd = "UPDATE Customer SET Name = @vName, Password = @vPwd, Telephone = @vTelephone, " & _
"Address = @vAddress, Zip = @vZip, where UserID=@vId"
conn = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim cmd As OleDbCommand = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add("@vId", CType(e.Item.Cells(1).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vPwd", CType(e.Item.Cells(2).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vName", CType(e.Item.Cells(3).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vTelephone", CType(e.Item.Cells(4).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vAddress", CType(e.Item.Cells(5).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vZip", CType(e.Item.Cells(6).Controls(0), TextBox).Text)
Try
conn.Open()
cmd.ExecuteNonQuery()
_gd1.EditItemIndex = -1
Finally
conn.Dispose()
End Try
BindGrid()
End Sub
my table is a normal table with some fields(UserID,Name,Password,Address,Telephone,Zip).. can u
pls help?? tks a lot..
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
o i c.... only Password is in square brackets..rest are not right?? i dont understand why is password in square brackets and rest are not.... i dont understand what is meant by KEYWORD WRAP??? can u pls shed some light on what kind of parameters should be inside
square brackets and what kind should be not.. also on what is keyword wrap.... tks a lot... really appreciate your help.. i learnt a lot of stuff... tks..
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
> i dont understand what is meant by KEYWORD WRAP??? Keywords are words that have special meaning in a language, any language, e.g. SQL, VB, C etc. Examples of keywords for SQL are SELECT, INSERT, IN, VALUES etc. When you are using such keywords as column names
(or alias names etc) inside you sql statement, you must enclose them in square brackets. This is the normal practice with Jet SQL (Access) and T-SQL (SQL Server) statements. Example: SELECT CustName, [Full Name], [Order] FROM Table1 ORDER BY CustName You can
also enclose column, alias names etc that contain spaces or unusual characters inside square brackets. Hope this helps a little bit.
i did as you said and took off the extra comma..but now i get this error: Server Error in '/InTouchDataGrid' Application. -------------------------------------------------------------------------------- Operation must use an updateable query. 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.OleDb.OleDbException: Operation must use an
updateable query. Source Error: Line 80: Try Line 81: conn.Open() Line 82: cmd.ExecuteNonQuery() Line 83: _gd1.EditItemIndex = -1 Line 84: Finally Source File: c:\inetpub\wwwroot\InTouchDataGrid\WebForm1.aspx.vb Line: 82 can u pl stell me what wrong?? this
is the code i am using
Public Sub gd1_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Dim updateCmd As String
Dim conn As OleDbConnection
Dim contract As Boolean
updateCmd = "UPDATE Customer SET Name = @vName, [Password] = @vPwd, Telephone = @vTelephone, " & _
"Address = @vAddress, Zip = @vZip where UserID=@vId"
conn = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim cmd As OleDbCommand = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add("@vId", CType(e.Item.Cells(1).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vPwd", CType(e.Item.Cells(2).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vName", CType(e.Item.Cells(3).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vTelephone", CType(e.Item.Cells(4).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vAddress", CType(e.Item.Cells(5).Controls(0), TextBox).Text)
cmd.Parameters.Add("@vZip", CType(e.Item.Cells(6).Controls(0), TextBox).Text)
Try
conn.Open()
cmd.ExecuteNonQuery()
_gd1.EditItemIndex = -1
Finally
conn.Dispose()
End Try
BindGrid()
End Sub
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 25, 2003 05:31 PM|LINK
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 25, 2003 05:37 PM|LINK
Public Sub gd1_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Dim updateCmd As String Dim conn As OleDbConnection Dim contract As Boolean updateCmd = "UPDATE Customer SET Name = @vName, Password = @vPwd, Telephone = @vTelephone, " & _ "Address = @vAddress, Zip = @vZip, where UserID=@vId" conn = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim cmd As OleDbCommand = New OleDbCommand(updateCmd, conn) cmd.Parameters.Add("@vId", CType(e.Item.Cells(1).Controls(0), TextBox).Text) cmd.Parameters.Add("@vPwd", CType(e.Item.Cells(2).Controls(0), TextBox).Text) cmd.Parameters.Add("@vName", CType(e.Item.Cells(3).Controls(0), TextBox).Text) cmd.Parameters.Add("@vTelephone", CType(e.Item.Cells(4).Controls(0), TextBox).Text) cmd.Parameters.Add("@vAddress", CType(e.Item.Cells(5).Controls(0), TextBox).Text) cmd.Parameters.Add("@vZip", CType(e.Item.Cells(6).Controls(0), TextBox).Text) Try conn.Open() cmd.ExecuteNonQuery() _gd1.EditItemIndex = -1 Finally conn.Dispose() End Try BindGrid() End Submy table is a normal table with some fields(UserID,Name,Password,Address,Telephone,Zip).. can u pls help?? tks a lot..SushilaSB
Star
11417 Points
2265 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 12:36 AM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 01:42 AM|LINK
updateCmd = "UPDATE Customer SET Name = @vName, Password = @vPwd, Telephone = @vTelephone, " & _ "Address = @vAddress, Zip = @vZip, where UserID=@vId"toupdateCmd = "UPDATE Customer SET [Name] = @vName, [Password] = @vPwd, Telephone = @vTelephone, " & _ "[Address] = @vAddress, [Zip] = @vZip where [UserID]=@vId"i have also applied the square barackets as you told me to...is it ok now???(the extra comma taken off and square brackets applied??) tks alot..SushilaSB
Star
11417 Points
2265 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 03:58 AM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 05:59 AM|LINK
salman_arsha...
Member
186 Points
38 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 07:19 AM|LINK
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 10:08 AM|LINK
joseph-r-tho...
Member
690 Points
138 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 10:13 AM|LINK
Public Sub gd1_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Dim updateCmd As String Dim conn As OleDbConnection Dim contract As Boolean updateCmd = "UPDATE Customer SET Name = @vName, [Password] = @vPwd, Telephone = @vTelephone, " & _ "Address = @vAddress, Zip = @vZip where UserID=@vId" conn = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim cmd As OleDbCommand = New OleDbCommand(updateCmd, conn) cmd.Parameters.Add("@vId", CType(e.Item.Cells(1).Controls(0), TextBox).Text) cmd.Parameters.Add("@vPwd", CType(e.Item.Cells(2).Controls(0), TextBox).Text) cmd.Parameters.Add("@vName", CType(e.Item.Cells(3).Controls(0), TextBox).Text) cmd.Parameters.Add("@vTelephone", CType(e.Item.Cells(4).Controls(0), TextBox).Text) cmd.Parameters.Add("@vAddress", CType(e.Item.Cells(5).Controls(0), TextBox).Text) cmd.Parameters.Add("@vZip", CType(e.Item.Cells(6).Controls(0), TextBox).Text) Try conn.Open() cmd.ExecuteNonQuery() _gd1.EditItemIndex = -1 Finally conn.Dispose() End Try BindGrid() End SubSushilaSB
Star
11417 Points
2265 Posts
Re: sql statement in VB.NET for MsAccess
Dec 26, 2003 02:55 PM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb