重新运行程序,所有数据库数据全部清空?!
我想要把mysql数据库中的一些字段值复制到access的一个表中的对应字段
oleDbInsertCommand1是通过oledbadapter控制拖放自动生成的,access连接正常
mysql连接正常,运行后结果正常。
但是,
如果关闭程序重新运行,那么刚才插入的所有记录全部清空了!
望高手不吝赐教,感激不尽!
string SqlStr = "select userid,tname,email from dede_admin ";
MySqlConnectionStringBuilder myDbconnString = new MySqlConnectionStringBuilder();
myDbconnString.Server = "noise.xicp.net ";
myDbconnString.Database = "noise ";
myDbconnString.UserID = "root ";
myDbconnString.Password = "Y3hR21EUI ";
myDbconnString.Port = 3306;
MySqlConnection DBconn = new MySqlConnection(myDbconnString.ConnectionString);
DBconn.Open();
MySqlCommand myCommand = new MySqlCommand(SqlStr, DBconn);
MySqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
oleDbConnection1.Open();
oleDbInsertCommand1.CommandText = "insert into [xuser] (userid,tname,email) values( ' "+myReader[ "userid "]+ " ', ' "+myReader[ "tname "]+ " ', ' "+myReader[ "email "]+ " ') ";
oleDbInsertCommand1.ExecuteNonQuery();
oleDbConnection1.Close();
}
myReader.Close();
------解决方案--------------------不是这里的问题
你应该找找程序启动后都做了些什么