这样吧你那程序我也打不开,写段代码来解释这个过程,用ADO简单讲解一下:
using SystemDataSqlClient;void charu(string zhi1;int zhi2) //插入你的数据
{
SqlConnection cnn=new SqlConnection();
cnnConnectionString="Server=SQL地址服务器1;uid=;pwd=;DataBase=数据库1";
cnnOpen();
DataSet ds=new DataSet();
SqlDataAdapter sda=new SqlDataAdapter("Insert Into 要插入的表(字段1,字段2)values('"+zhi1+"','"+zhi2+"')",cnn);
sdaFill(ds);
}
void genxincaozuo(string tiaojian) //检索你要插入的数据一条一条插入
{
SqlConnection cnn=new SqlConnection();
cnnConnectionString="Server=SQL地址服务器2;uid=;pwd=;DataBase=数据库2";
try{
cnnOpen();
DataSet ds=new DataSet();
SqlDataAdapter sda=new SqlDataAdapter("Select from 准备插入的表 where 条件字段='"+tiaojian+"'",cnn);
sdaFill(ds);
for(int i=0;i<dsTables[0]RowsCount;i++) //把要插入的数据遍历
{
string str1=dsTables[0]Rows[i]["字段名1"]ToString();
int Z1=ConvertToInt32(dsTables[0]Rows[i]["字段名2"]ToString());
charu(str1,Z1); //在这里嵌套插入函数
}
catch(SQL Exception e)
{
MessageBoxShow(eToString());
}
finnaly
{
cnnClose();
}
}
}
这个办法是堆栈办法,ADO最简单的方法,也相对比较快一点,用Session就是表对表插入,比这个更浪费时间,
以上就是关于用C#把mySQL数据插入msSQL数据库全部的内容,包括:用C#把mySQL数据插入msSQL数据库、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)