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
shailendra verma
1.3k
399
3.4k
implicit conversion from data type varchar to varbinary(max)
Nov 29 2018 12:40 AM
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
string contentType = FileUpload1.PostedFile.ContentType;
using (Stream fs = FileUpload1.PostedFile.InputStream)
{
using (BinaryReader br = new BinaryReader(fs))
{
byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
string query = "UPDATE tblFiles SET Name='" + filename.ToString() + "',ContentType='" + contentType.ToString() + "',Data='" + ((object)bytes) + "' WHERE id = '" + 1 + "'"; //Getting error
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);
Reply
Answers (
2
)
Session Mode use outproc mode in ASP.NET?
Button click event not firing up