TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akhter HUssain
712
1.3k
103.4k
Incorrect syntax near ‘SET’ in asp.net c#
Aug 28 2019 10:46 AM
When i updating record then this error is coming...please guide
below mentioned behind update button code
int
id =
int
.Parse(lbid.Text);
string
filePath = FileUpload1.PostedFile.FileName;
string
customername = txtcus.Text;
string
filename = Path.GetFileName(filePath);
string
ext = Path.GetExtension(filename);
string
contenttype = String.Empty;
switch
(ext) {
case
".doc"
:
contenttype =
"application/vnd.ms-word"
;
break
;
case
".docx"
:
contenttype =
"application/vnd.ms-word"
;
break
;
case
".xls"
:
contenttype =
"application/vnd.ms-excel"
;
break
;
case
".xlsx"
:
contenttype =
"application/vnd.ms-excel"
;
break
;
case
".jpg"
:
contenttype =
"image/jpg"
;
break
;
case
".png"
:
contenttype =
"image/png"
;
break
;
case
".gif"
:
contenttype =
"image/gif"
;
break
;
case
".pdf"
:
contenttype =
"application/pdf"
;
break
;
}
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br =
new
BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32) fs.Length);
//string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
//SqlConnection con = new SqlConnection(constr);
string
query =
"UPDATE Customer SET "
;
SqlCommand cmd =
new
SqlCommand(query, con);
if
(!
string
.IsNullOrEmpty(customername)) {
query +=
"CustomerName =@CustomerName,"
;
cmd.Parameters.AddWithValue(
"@CustomerName"
, customername);
}
if
(!
string
.IsNullOrEmpty(filename)) {
query +=
"Name = @Name,"
;
cmd.Parameters.Add(
"@Name"
, SqlDbType.VarChar).Value = filename;
}
if
(bytes.Length > 0) {
query +=
"Data=@Data,"
;
cmd.Parameters.Add(
"@Data"
, SqlDbType.Binary).Value = bytes;
}
if
(!
string
.IsNullOrEmpty(contenttype)) {
query +=
"ContentType=@ContentType,"
;
cmd.Parameters.Add(
"@ContentType"
, SqlDbType.VarChar).Value = contenttype;
}
query = query.TrimEnd(
','
);
query +=
" WHERE CustomerId =@Id"
;
cmd.Parameters.AddWithValue(
"@Id"
, id);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Reply
Answers (
11
)
trying to open an access report from c#
System.Net.Socket Error using Azure-Iot-device-read-message