Hi,
you can use this code:
SqlCommand com = new SqlCommand();
com.CommandText = "SaveDocument";
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@OrigName", SqlDbType.VarChar).Value = this.origname;
SqlParameter param = com.Parameters.Add("@data", SqlDbType.Image);
FileStream file = new FileStream( physicalname, FileMode.Open);
byte[] buff = new byte [ file.Length];
file.Read(buff, 0, Convert.ToInt32(file.Length));
file.Close();
param.Value = buff;
id = Convert.ToInt32( DataProvider.ExecuteScalar( com) );
Note that I'm reading all the file in memory (dont if this is your case) I'm
dealing with small files so I can do this.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
I have a binary data to write to sql database by using a stored procedure.
What is the syntax for data type passed to the following call for adding
the
parameter? What if the data is longer than 8000 bytes?
cmd.Parameters.Add("Data", "data type");