| | |
Update Command
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 4
Reputation:
Solved Threads: 0
Hi all,
I am using asp and vb and back end is SQL .
I am getting syntax error in update command. Error is Incorrect Syntax near keyword "desc".
Can anyone debug this.
R can you tell me an alternative way to update record in database.
I have to check 3conditions in order to update a record.
This is the statement i have given.
com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'", con)
I am using asp and vb and back end is SQL .
I am getting syntax error in update command. Error is Incorrect Syntax near keyword "desc".
Can anyone debug this.
R can you tell me an alternative way to update record in database.
I have to check 3conditions in order to update a record.
This is the statement i have given.
com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'", con)
com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'", con)
try type new not New
and add ; at the end of statement
If you need another way:
on my i use stored procedure and pass values as a parameter and it is more accurate than execute and pass command from .net application.
here is the code:
database code:
asp.net code
hope it usefull
try type new not New
and add ; at the end of statement
If you need another way:
on my i use stored procedure and pass values as a parameter and it is more accurate than execute and pass command from .net application.
here is the code:
database code:
ASP.NET Syntax (Toggle Plain Text)
CREATE PROCEDURE ChangeProductDetails @Price int , "you specify the data types of parameters according to your fields in database" @Qty int, @Desc nvarchar(50), @Cname nvarchar(50), @Pname nvarchar(50), @Mno nvarchar(50) AS update prod_details set price = @Price, qty=@Qty, desc = @Desc where cname = @Cname and pname= @Pname and mno = @Mno GO
ASP.NET Syntax (Toggle Plain Text)
SqlCommand Cmd_UpdateProducts = new SqlCommand("ChangeProductDetails",con); Cmd_UpdateProducts.CommandType = CommandType.StoredProcedure; //passing parameters to command SqlParameter Price= Cmd_UpdateProducts.Parameters.Add("@Price",SqlDbType.Int); Price.Value = txt_Price.Text; SqlParameter Qty = Cmd_UpdateProducts.Parameters.Add("@Qty",SqlDbType.Int); Qty.Value = txt_Qty.Text; SqlParameter desc = Cmd_UpdateProducts.Parameters.Add("@Desc",SqlDbType.NVarChar); desc.Value = txt_desc.Text; SqlParameter Cname = Cmd_UpdateProducts.Parameters.Add("@Cname",SqlDbType.NVarChar); Cname.Value = txt_Cname.Text; SqlParameter Pname = Cmd_UpdateProducts.Parameters.Add("@Pname",SqlDbType.NVarChar); Pname.Value = txt_Pname.Text; SqlParameter Mno= Cmd_UpdateProducts.Parameters.Add("@Mno",SqlDbType.NVarChar); Mno.Value = txt_Mno.Text; con.Open(); Cmd_UpdateProducts.ExecuteNonQuery(); con.Close();
•
•
Join Date: Oct 2008
Posts: 1
Reputation:
Solved Threads: 0
[QUOTE=Enjoy;707992]Hi all,
I am using asp and vb and back end is SQL .
I am getting syntax error in update command. Error is Incorrect Syntax near keyword "desc".
Can anyone debug this.
R can you tell me an alternative way to update record in database.
I have to check 3conditions in order to update a record.
This is the statement i have given.
[B]com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'"), con
I am using asp and vb and back end is SQL .
I am getting syntax error in update command. Error is Incorrect Syntax near keyword "desc".
Can anyone debug this.
R can you tell me an alternative way to update record in database.
I have to check 3conditions in order to update a record.
This is the statement i have given.
[B]com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'"), con
•
•
Join Date: May 2008
Posts: 144
Reputation:
Solved Threads: 9
com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',desc='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'", con)
change desc field name in your table
coz desc is reserved keyword.
change desc field name in your table
coz desc is reserved keyword.
Hi,
coz desc is reserved keyword.
but you can still use it.
so change it to
Thanks.
coz desc is reserved keyword.
but you can still use it.
so change it to
ASP.NET Syntax (Toggle Plain Text)
com = New SqlCommand("Update prod_details Set price ='" & price.Text & "',qty='" & qty.Text & "',[desc]='" & desc.Text & "' where cname='" & cname.Text & "' and pname= '" & pname.Text & "' and mno= '" & mno.Text & "'", con)
Thanks.
NEVER NEVER NEVER GIVE UP
![]() |
Similar Threads
- MYSQL: update all fields in a table (increase value by one) (PHP)
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- Sending update commands directly (C#)
- UPDATE query problem (ASP.NET)
- How to Update a Data Table? (ASP.NET)
- oleDbCommand - Update (ASP.NET)
- how do i update to Access db? (C#)
- C# Command Line Application (C#)
- Problem using the UPDATE command in VBA (Visual Basic 4 / 5 / 6)
Other Threads in the ASP.NET Forum
- Previous Thread: who knows php and asp.net? need help with this script! very confused!
- Next Thread: searching a record
Views: 2396 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox child class complex contenttype control countryselector database datagrid datagridview datalist deployment development dgv dialog dropdownmenu dynamic dynamically edit editing embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form gridview gudi identity iis image javascript languages list maps menu mobile mssql nameisnotdeclared novell opera order parent problem profile radio redirect refer registration relationaldatabases reportemail response.redirect richtextbox rows search security select serializesmo.table services sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb vb.net vista visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming wizard xsl





