string path = "c://test.doc";
string conn = "";//连接字符串
FileStream file = new FileStream(path);
byte[] buffer = new byte[1024*1024];
int i1=0,i2=buffer.Length;
while (i2 > 0)
{
int m = file.Read(buffer,0,buffer.Length);
if (m <= 0) break;
i1+=m;
i2-=m;
}
byte[] temp = new byte[i1];
Array.Copy(buffer,temp,i1);
buffer = temp;
SqlCommand cmd = new SqlCommand("insert into table1 value @doc" );
((SqlParameter)cmd.Parameters.Add("@doc",buffer)).DbType = DbType.Binary;
cmd.Connection = new SqlConnection(conn).Open();
int result = cmd.ExecuteNonQuery();
cmd.Connection.Close();