Can you do an insert statement with multiple file blob reads in the same command?
In the code below inputfile contains the following:
string[] inputfile = {"C:\\test_blob\\blob1.pdf","C:\\test_blob\\blob2.jpg"};
I'm uncertain if cmd.Parameters can be done prior to the cmd.CommandText or if I can do more than one File.ReadAllBytes() as a cmd.Parameter.
public static void insert_blob_file(string dbname, string uid, string pwd, string[] inputfile)
{
using (var conn = new OdbcConnection("DSN=" + dbname + ";UID=" + uid + ";pwd=" + pwd))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
for (int i = 0; i < inputfile.Count();i++)
{
var inputStream = new FileStream[i];
using (inputStream[i] = File.OpenRead(inputfile[i]))
{
cmd.Parameters.AddWithValue("blob" + i.ToString(), File.ReadAllBytes(inputfile[i]));
}
cmd.CommandText = "INSERT INTO MyTable (Id, MyBlobColumn,String1,MyBlobColum1,String2,String3) VALUES (1,@blob0,SomeString,@blob1,SomeString,SomeString)";
}
cmd.ExecuteNonQuery();
}
conn.Close();
}
}