hi everyone ,
please help me how to insert txt file into database sever please provide me code
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sreekanth ReddyPosted Apr 6, 2017, 6:21 AM
Sreekanth ReddyPosted Apr 6, 2017, 6:14 AM
Abhishek SinghPosted Apr 6, 2017, 6:06 AM
Sreekanth ReddyPosted Apr 6, 2017, 5:14 AM
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
string strQuery = "insert into tblFiles(Name, ContentType, Data)" +
" values (@Name, @ContentType, @Data)";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = filename;
cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value
= contenttype;
cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes;