That was a typo when I edited the contents.
The real problem is that '?' is not accepted; the paremeter names have to be given in INSERT statement.
I got it working with the following code:
SqlCommand cmd = new SqlCommand("INSERT into Tab1 (CREATOR,CONTENTS) values(@CREATOR,@CONTENTS)
SqlParameter Creator = new SqlParameter("@CREATOR", SqlDbType.Char);
Creator .Value = "USER1";
cmd.Parameters.Add(Creator
FileStream fs = new FileStream(sFullFilePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] FileData = br.ReadBytes((int)fs.Lengt
SqlParameter Contents = new SqlParameter("@CONTENTS", SqlDbType.Image);
Contents .Value = FileData ;
cmd.Parameters.Add(Content
int i = cmd.ExecuteNonQuery();
--------------
This works only on SQL Server; when I use ODBCCommand this does not work; I think I will have to use '?' instead of parameter names in the INSERT T statement.
Main Topics
Browse All Topics





by: hongjunPosted on 2009-04-21 at 09:06:07ID: 24195976
Your file path is incorrect. You are missing the colon.
Use this instead.
Select allOpen in new window