karthi vimala

karthi vimala

  • NA
  • 49
  • 50.2k

update the binarydata to sqltable in .net

Mar 29 2011 2:14 AM
hi,

    i tried to update the binary data to a sqltable from .net.i used the codings like this

BinaryReader

error:

Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.

error will occur how can i solve this

br = new BinaryReader(FileUpload1.PostedFile.InputStream);
byte[] b1 = br.ReadBytes(FileUpload1.PostedFile.ContentLength);
string strconn = @"data source=.\sqlexpress;initial catalog=jobs;uid=sa;pwd=as";
SqlConnection conn = new SqlConnection(strconn);
string q1 = "update register set resume='" + b1 + "' where id='" + id1+ "'";
SqlCommand cmd = new SqlCommand(q1, conn);
SqlDataReader rdr = null;
rdr = cmd.ExecuteReader();

Answers (5)