我找了很多资料都是SQL SERVER2000存取二进制文件的实例。
将这个实例改变成用OLEDB方式的后,无法正常运行!哪个大哥帮帮忙,解决一下!十分感谢!
string strDSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\NewMDB.mdb;Jet OLEDB:Database Password=1;";
string strSQL = "SELECT * FROM Test_Table";
OleDbConnection con = new OleDbConnection(strDSN);
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, con);
OleDbCommandBuilder MyCB = new OleDbCommandBuilder(da);
DataSet ds = new DataSet("Test_Table");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\1.jpg", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData= new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds,"Test_Table");
DataRow myRow;
myRow=ds.Tables["Test_Table"].NewRow();
//myRow["Description"] = "This would be description text";
myRow["Test1"] = MyData;
ds.Tables["Test_Table"].Rows.Add(myRow);
da.Update(ds,"Test_Table");
con.Close();
将这个实例改变成用OLEDB方式的后,无法正常运行!哪个大哥帮帮忙,解决一下!十分感谢!
string strDSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\NewMDB.mdb;Jet OLEDB:Database Password=1;";
string strSQL = "SELECT * FROM Test_Table";
OleDbConnection con = new OleDbConnection(strDSN);
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, con);
OleDbCommandBuilder MyCB = new OleDbCommandBuilder(da);
DataSet ds = new DataSet("Test_Table");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\1.jpg", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData= new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds,"Test_Table");
DataRow myRow;
myRow=ds.Tables["Test_Table"].NewRow();
//myRow["Description"] = "This would be description text";
myRow["Test1"] = MyData;
ds.Tables["Test_Table"].Rows.Add(myRow);
da.Update(ds,"Test_Table");
con.Close();
comm.Parameters.Add(param1, "This would be description text");
comm.Parameters.Add(param2, MyData);
comm.ExecuteNonQuery();