代码如下
PubConnstr = "provider=MSDASQL.1;user id=admin;password=;driver=microsoft visual foxpro driver;sourcedb="+Pathstr+";sourcetype=dbf;Persist Security Info=False";//用ODBC连接一个FOXPRO数据库.
OdbcConn.ConnectionString = PubConnstr;
OdbcConn.Open();
sqlstr="SELECT * FROM PIAOLST";
OdbcComm.CommandText =sqlstr;
OdbcComm.ExecuteNonQuery();
OdbcData.Fill(TmpDsc,"piaolst");//这里得到并填充数据
for(k = 0; k < TmpDsc.Tables[0].Rows.Count ; k++)//循环插入本地库CURRDAYBUSINFO(ACCESS类型的)
{
sqlstr="INSERT INTO CurrDayBusinfo(num,times,name,linenum,counter1,limt,km,bc,qnum,name1,dayxy,piaodj,chknum,days,recnum,"
+"types,memos,model,fache,facname,facnum,fjsxf,cw,isprntime,fsit,hc,resone,hl)"//zdt,fhj
+"values("+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[0].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[1].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[2].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[3].ToString().Trim()+"'"+","
+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[4].ToString())+","+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[5].ToString())+","+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[6].ToString())+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[7].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[8].ToString().Trim()+"'"+","
+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[9].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[10].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[11].ToString().Trim()+"'"+","+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[12].ToString())+","+"#"+TmpDsc.Tables[0].Rows[k].ItemArray[13].ToString().Trim()+"#"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[14].ToString().Trim()+"'"+","
+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[15].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[16].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[17].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[18].ToString().Trim() +"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[19].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[20].ToString().Trim()+"'"+","
+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[21].ToString())+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[22].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[23].ToString().Trim() +"'"+","+int.Parse(TmpDsc.Tables[0].Rows[k].ItemArray[24].ToString())+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[25].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[26].ToString().Trim()+"'"+","+"'"+TmpDsc.Tables[0].Rows[k].ItemArray[27].ToString().Trim()+"'"+")";
OleDbComm.CommandText =sqlstr;
OleDbComm.ExecuteNonQuery();//第循环一次插入一条记录,这样太慢了.
txt_info.Text="本地数据库插入记录信息:"+k.ToString().Trim()+" 条";
txt_info.Refresh();
}
以上是一条一条插入的方法,太慢了.主要是两种类型的数据库,我现在不清楚的是用ODBC查询到的数据,怎么才能把它一次性插入到一个用OLECONNECTION连接上的ACCESS里,?????????????