Your dynamic SQL code has bugs. Please take a few moments out of your day to use the Visual Studio debugger to step through your code. You can get this error if none of the condition statements are entered but single stepping through your code will highlight
bugs rather quickly.
mgebhard,i just did my debug code ,i did not find any empty record or null value
You did not take a look at "query"? If a condition is entered more than one then query becomes...
UPDATE Customer SET UPDATE Customer SET CustomerName =@CustomerName, UPDATE Customer SET UPDATE Customer SET CustomerName =@CustomerName, Name = @Name WHERE CustomerId =@Id
If the condition is entered only one the query becomes.
UPDATE Customer SET UPDATE Customer SET CustomerName =@CustomerName WHERE CustomerId =@Id
You can learn how to use the Visual Studio debugger at the following link. Pay special attention to single stepping and viewing variable.
Now both value customer name and image is getting update ,but after updating image ,image is not getting display ,i am sharing image of table column status of data (last record ,i used your code to update ,in which data value is coming different as compare
my second last record with same image,,) please guide...
Member
116 Points
274 Posts
Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 03:45 PM|akhterr|LINK
when i updating record then this error is coming that
Incorrect syntax near 'SET'
please guide here is my code ...for update button
All-Star
53041 Points
23611 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 04:26 PM|mgebhard|LINK
Your dynamic SQL code has bugs. Please take a few moments out of your day to use the Visual Studio debugger to step through your code. You can get this error if none of the condition statements are entered but single stepping through your code will highlight bugs rather quickly.
Member
116 Points
274 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 04:30 PM|akhterr|LINK
Please take a few moments out of your day to use the Visual Studio debugger to step through your code.
All-Star
53041 Points
23611 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 04:58 PM|mgebhard|LINK
I'll give you a hint... what happens to "query" if more than one condition is entered? What happens if none of the conditions are entered?
Member
116 Points
274 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 05:02 PM|akhterr|LINK
hi,
mgebhard,i just did my debug code ,i did not find any empty record or null value
All-Star
53041 Points
23611 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 05:13 PM|mgebhard|LINK
You did not take a look at "query"? If a condition is entered more than one then query becomes...
If the condition is entered only one the query becomes.
You can learn how to use the Visual Studio debugger at the following link. Pay special attention to single stepping and viewing variable.
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019
https://docs.microsoft.com/en-us/visualstudio/debugger/navigating-through-code-with-the-debugger?view=vs-2019
Member
116 Points
274 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 05:23 PM|akhterr|LINK
so what else can be done...
All-Star
53041 Points
23611 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 28, 2019 05:31 PM|mgebhard|LINK
Well, first you should understand the problem. Then solve the problem.
All-Star
52673 Points
15720 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 29, 2019 01:24 AM|oned_gk|LINK
Not sure, maybe reserved word there, try like below
Suwandi - Non Graduate Programmer
Contributor
3140 Points
983 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 29, 2019 02:11 AM|Yang Shen|LINK
Hi akhterr,
According to your code, your cmd.command is "UPDATE Customer SET " which is never changed in your whole event.
In fact, you can't do
AFTER you already bound the cmd.command at
Please refer to below demo and modify your code:
.ASPX:
.CS:
SQL:
Below is the result of this demo and how you can debug your code in VS:
Best Regard,
Yang Shen
Member
116 Points
274 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 29, 2019 05:38 AM|akhterr|LINK
Thanks for support ,Yang Shen,,,
Now both value customer name and image is getting update ,but after updating image ,image is not getting display ,i am sharing image of table column status of data (last record ,i used your code to update ,in which data value is coming different as compare my second last record with same image,,) please guide...
https://ibb.co/Mh65PVt
Contributor
3140 Points
983 Posts
Re: Incorrect syntax near 'SET' in asp.net c#
Aug 29, 2019 05:56 AM|Yang Shen|LINK
Hi akhterr,
It seems it's a data length related issue, will you share us your table structure to check the data type of your [Data]?
Or you can try change the "n" in below code to an appropriate number:
Best Regard,
Yang Shen