Hello,
I'm looking for a workaround, my destination server (Rainingdata D3) is returning an error when my reader is returning to much lines. explications: 1 datareader reads from my sqlite database, 2 via a while reader-loop i'm inserting in the destination database (ODBC- D3 database) i don't have a other solution oder other dataprovider. I get an error after about 500 lines. The select is returning between 50 000 and 1 500 000 lines. If somebody could give me an idea to limit/split the select phrases in smaller queries via a loop. thanks
sqLiteConnection1.ConnectionString = "Data Source=" + textBox1.Text.ToString() + ";New=True;Compress=True;Journal Mode=Off;Cache Size=2000;Page Size=1024";
myCommand.Connection = sqLiteConnection1;
sqLiteConnection1.Open();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
SQLiteDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
D3connection.ConnectionString = "Dsn=" + STOCKIX.SelectedItem.ToString();
D3connection.Open();
toolStripProgressBar1.Visible = true;
toolStripProgressBar1.Maximum = recordcount;
toolStripProgressBar1.Minimum = 0;
toolStripProgressBar1.Value = 0;
toolStripProgressBar1.Step = 1;
try
{
using (OdbcTransaction mytransaction = D3connection.BeginTransaction())
{
using (OdbcCommand insertCommand = new OdbcCommand(null, D3connection))
{
insertCommand.Transaction = mytransaction;
//if (reader != null)
if (reader.HasRows)
{
while (reader.Read())
{
insertCommand.CommandText = "INSERT INTO " + comboBox2.Text +
" (ART_R_CODE, ART_R_REF, ART_R_DESI, ART_R_FOUR, ART_R_GRP, ART_R_CONDI, ART_R_EAN, ART_R_REM1)" +
" VALUES ('" // Col_TO
+ cmbPrefix.Text.ToString() + reader.GetValue(2).ToString() + "', '" // ART_R_CODE
+ reader.GetValue(2).ToString() + "', '" // ART_R_REF
+ reader.GetValue(3).ToString() + "', '" // ART_R_DESI
+ cmbCodeFour.Text.ToString() + "', '" // ART_R_FOUR
//+ reader.GetValue(3).ToString() + "', '" // ART_R_PBF
+ cmbGroupe.Text.ToString() + "', '" // ART_R_GRP
+ reader.GetValue(4).ToString() + "', '" // ART_R_CONDI
+ reader.GetValue(2).ToString() + "', '" // ART_R_EAN
+ "0" + "')";//+ reader.GetValue(9).ToString() + "')"; // ART_R_REM1 9
insertCommand.ExecuteNonQuery();
toolStripProgressBar1.PerformStep();
int elapsedTime = Convert.ToInt32(stopWatch.ElapsedMilliseconds.ToString());
toolStripStatusLabel1.Text = "Elapsed time: " + elapsedTime / 1000 + " sec.";
Application.DoEvents();
}
//while (reader.NextResult() == true) ;
}
else
{
}
}
// Commit the transaction.
mytransaction.Commit();
}
MessageBox.Show("Insert OK", "Insert OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
}