我现在把DBF中的3500多行记录插入到oracle ,过程当中报ORA-01000: 超出打开游标的最大数 这个错误,只插入300行。请各位老大看看我代码有什么不妥。
OleDbConnection dbfconn = new OleDbConnection();
OleDbConnection oraconn = new OleDbConnection();
string xm,hz;
string SQL = "";
string sql1="";
try
{
//string dir = Server.MapPath(@"d:\ykchr");
// dbfconn.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filepath+";Jet OLEDB:Database Password=yksoft1919;" ;
// dbfconn.Open();
dbfconn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=c:\\person.dbf;Mode=ReadWrite|Share Deny None;Extended " +
"Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache Authentication=Fa" +
"lse;Encrypt Password=False;Collating Sequence=MACHINE;DSN=\"\"";
dbfconn.Open();
oraconn.ConnectionString ="Provider=OraOLEDB.Oracle.1;User ID=test_appdb;Password=missrain;Data Source=MIS;Extended Properties=;Persist Security Info=True";
oraconn.Open();
SQL ="SELECT * from person ";
OleDbCommand cmd = new OleDbCommand(SQL,dbfconn);
OleDbDataReader reader;
reader=cmd.ExecuteReader();
while(reader.Read())
{
SQL="insert into hr_t_employee_base_copy(employeename,employeecode,employeeid,birthdate) values ('"+reader["name"].ToString()+"','"+reader["xh"].ToString()+"','"+reader["xh"].ToString()+"','"+Convert.ToDateTime(reader["birthday"])+"')";
cmd = new OleDbCommand(SQL,oraconn);
cmd.ExecuteNonQuery();
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
dbfconn.Close();
oraconn.Close();
}
OleDbConnection dbfconn = new OleDbConnection();
OleDbConnection oraconn = new OleDbConnection();
string xm,hz;
string SQL = "";
string sql1="";
try
{
//string dir = Server.MapPath(@"d:\ykchr");
// dbfconn.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filepath+";Jet OLEDB:Database Password=yksoft1919;" ;
// dbfconn.Open();
dbfconn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=c:\\person.dbf;Mode=ReadWrite|Share Deny None;Extended " +
"Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache Authentication=Fa" +
"lse;Encrypt Password=False;Collating Sequence=MACHINE;DSN=\"\"";
dbfconn.Open();
oraconn.ConnectionString ="Provider=OraOLEDB.Oracle.1;User ID=test_appdb;Password=missrain;Data Source=MIS;Extended Properties=;Persist Security Info=True";
oraconn.Open();
SQL ="SELECT * from person ";
OleDbCommand cmd = new OleDbCommand(SQL,dbfconn);
OleDbDataReader reader;
reader=cmd.ExecuteReader();
while(reader.Read())
{
SQL="insert into hr_t_employee_base_copy(employeename,employeecode,employeeid,birthdate) values ('"+reader["name"].ToString()+"','"+reader["xh"].ToString()+"','"+reader["xh"].ToString()+"','"+Convert.ToDateTime(reader["birthday"])+"')";
cmd = new OleDbCommand(SQL,oraconn);
cmd.ExecuteNonQuery();
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
dbfconn.Close();
oraconn.Close();
}
解决方案 »
- 难道就没人遇到过这样的问题
- 新手求解
- 各位大虾,弟子出学c#,想下一个visual C# express,要中文版的,并且不要visual studio太大了,装不下。能否告诉我地址?我下了好多还是
- DataGirdView.DataSource的问题
- 《Visual C# .NET精彩编程实例集锦》配套光盘文件-只有代码.....加精.....
- 找不到类型或命名空间名称“Graphics”(是否缺少 using 指令或程序集引用?)
- dataview的问题?
- 不知道怎么才能把Pubwin搞掉?
- 求一个导出word 方案
- 关于StreamWriter的菜鸟问题
- 线程的简单问题
- 关于Nant的问题
OleDbConnection dbfconn = new OleDbConnection();
OleDbConnection oraconn = new OleDbConnection();
string xm,hz;
string SQL = "";
string sql1="";
try
{
dbfconn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=c:\\person.dbf;Mode=ReadWrite|Share Deny None;Extended " +
"Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache Authentication=Fa" +
"lse;Encrypt Password=False;Collating Sequence=MACHINE;DSN=\"\"";
dbfconn.Open();
oraconn.ConnectionString ="Provider=OraOLEDB.Oracle.1;User ID=test_appdb;Password=missrain;Data Source=MIS;Extended Properties=;Persist Security Info=True";
oraconn.Open();
SQL ="SELECT * from person ";
OleDbCommand cmd = new OleDbCommand(SQL,dbfconn);
OleDbDataReader reader;
reader=cmd.ExecuteReader();
while(reader.Read())
{
// SQL="insert into hr_t_employee_base_copy(employeename,employeecode,employeeid,birthdate) values ('"+reader["name"].ToString()+"','"+reader["xh"].ToString()+"','"+reader["xh"].ToString()+"','"+Convert.ToDateTime(reader["birthday"])+"')";
SQL="insert into hr_t_employee_base_copy(employeename,employeecode,employeeid,birthdate) values ('"+reader["name"].ToString()+"','"+reader["xh"].ToString()+"','"+reader["xh"].ToString()+"','"+Convert.ToDateTime(reader["birthday"])+"')";
cmd = new OleDbCommand(SQL,oraconn);
cmd.ExecuteNonQuery();
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
dbfconn.Close();
oraconn.Close();
}
http://www.zhuoda.org/hofman/24140.html
{
oraconn.ConnectionString ="Provider=OraOLEDB.Oracle.1;User ID=test_appdb;Password=missrain;Data Source=MIS;Extended Properties=;Persist Security Info=True";
oraconn.Open(); SQL="insert into hr_t_employee_base_copy(employeename,employeecode,employeeid,birthdate) values ('"+reader["name"].ToString()+"','"+reader["xh"].ToString()+"','"+reader["xh"].ToString()+"','"+Convert.ToDateTime(reader["birthday"])+"')";
cmd = new OleDbCommand(SQL,oraconn);
cmd.ExecuteNonQuery();
}
这样就可以啦