110,534
社区成员
发帖
与我相关
我的任务
分享
String connStr = "server='" + SeverName + "';Database='" + DBName + "';uid='" + UserName + "';pwd='" + UserPW + "'";
string sql="select * from t_a";
DataSet dt = new DataSet("t_a");//创建一个数据集dt
MySqlConnection Conn = new MySqlConnection(connStr);//定义新的数据连接控件并初始化
Conn.Open();//打开连接
MySqlDataAdapter reads = new MySqlDataAdapter(sql, Conn);//定义并初始化数据适配器
MySqlCommandBuilder cmb = new MySqlCommandBuilder(reads);
reads.MissingSchemaAction = MissingSchemaAction.AddWithKey;
reads.Fill(dt, "t_a"); //将数据适配器中的数据填充到数据集dt中
FileStream fs = new FileStream(@"E:\My Pictures\test.bmp", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
DataRow myRow;
myRow = dt.Tables["t_a"].NewRow();
myRow["image"] = MyData;
dt.Tables["t_a"].Rows.Add(myRow);
reads.Update(dt, "t_a");
Conn.Close();//关闭连接
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Dnq???>??8p??&??,?????HV{x???tR {[))???7???|lV?y??|?n??fu??G?Io????? 4?Rup??' at line 1
FileStream fs = new FileStream(@"E:\My Pictures\哈哈.txt", FileMode.OpenOrCreate, FileAccess.Read);
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DnqÕÎÚ>¹8pï¼& ø,惮£ÍHV{xÊÚtR {[))ÏÀí7Ïš|lVÜy‚ì|Õn’Ñfu¥ÆGéIoÂÕ¹µ¾ 4ûRupºˆ' at line 1