How to store a word file document in sqlserver using window application with c#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
my code:



private void btnSave_Click(object sender, EventArgs e)<br/>
{<br/>
<br/>
try<br/>
{<br/>
<br/>
string name = @"C:Documents and SettingsicoresoftDesktopmurali.doc";<br/>
<br/>
FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);<br/>
BinaryReader br = new BinaryReader(fs);<br/>
<br/>
byte[] bname = new byte[fs.Length];<br/>
fs.Read(bname, 0, Convert.ToInt32(fs.Length));<br/>
<br/>
tbal.my_doc = Convert .ToString (bname);<br/>
string name1 = "insert into test1(mydoc,isactive)values(" + tbal.my_doc + ",true)";<br/>
string i = da.ExecuteCmd(name1);<br/>
//string i = tdal.createfile(tbal);<br/>
if (i == "1")<br/>
{<br/>
MessageBox.Show("saved");<br/>
}<br/>
}<br/>
catch (Exception ex)<br/>
{<br/>
throw ex;<br/>
}<br/>
}

i got error for converting varcahr to varbinary PLEASE ANY ONE HELP

View the full article
 
Back
Top