arichexe
asked on
Inserting file into blob
The below C# snippet loads a .doc into a SQL image. How would I code such in VB.NET?
FileStream MyStream = new FileStream("C:\\My.doc",Fi leMode.Ope n);
int DocLen = (int)new FileInfo("C:\\My.doc").Len gth;
byte[] MyBlob = new byte[DocLen];
int n = MyStream.Read(MyBlob,0,Doc Len);
string MySql = "INSERT INTO MyBlobTable (MyId,MyBlob) VALUES (1,@MyBlob)";
SqlCommand sql = new SqlCommand(MySql,MyConn);
SqlParameter sqlp = new SqlParameter("@MyBlob",Sql DbType.Ima ge);
sqlp.Value = MyBlob;
sql.Parameters.Add(sqlp);
FileStream MyStream = new FileStream("C:\\My.doc",Fi
int DocLen = (int)new FileInfo("C:\\My.doc").Len
byte[] MyBlob = new byte[DocLen];
int n = MyStream.Read(MyBlob,0,Doc
string MySql = "INSERT INTO MyBlobTable (MyId,MyBlob) VALUES (1,@MyBlob)";
SqlCommand sql = new SqlCommand(MySql,MyConn);
SqlParameter sqlp = new SqlParameter("@MyBlob",Sql
sqlp.Value = MyBlob;
sql.Parameters.Add(sqlp);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I missed a \ character on the second line- you don't need to escape them in VB.