私のsqlite
データベースはC:\program-name\db\db.s3db
に格納されています。 私はテーブルmembers
と約70
のレコードを持っています。だから今私は、members
テーブルから他のテーブルact_monthly_listings
にすべての口座番号をコピーする必要がある手続きがあります。C#が非常にゆっくりと実行されているSQLiteデータベース
実行中であることを示していますが、それは退屈なほど遅いです。それが私のコードのためかどうかわかりません。ここでは抜粋です:
接続:
ButtonClickコードにprivate void SetConnection()
{
sql_con = new SQLiteConnection
("Data Source=C:\\credit-union\\db\\cu.s3db;Version=3;New=False;Compress=True;");
}
:
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Working Please Wait";
string init_month = dtInit.Value.Month.ToString();
string init_yr = dtInit.Value.Month.ToString();
SetConnection();
sql_con.Open();
SQLiteCommand cmd = new SQLiteCommand();
cmd.CommandText = "select ec_no from members";
cmd.Connection = sql_con;
DR = cmd.ExecuteReader();
int count = 0;
while (DR.Read())
{
DR.Read();
this.Text = "Account : " + DR.GetInt32(0).ToString();
string SQL = "INSERT INTO act_monthly_listings (year,month,act) VALUES ("+ init_yr + "," + init_month + "," + DR.GetInt32(0).ToString() + ")";
//Clipboard.SetText(SQL)
if (ExecuteQuery(SQL))
{
count++;
}
}
if(count > 0){
MessageBox.Show("Accounts Initialized!", "Success", MessageBoxButtons.OK,MessageBoxIcon.Information);
}else{
MessageBox.Show("Initialization Failed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
sql_con.Close();
}
これは 'while'のためかもしれません。なぜなら、あなたは' INSERT INTO -SELECT 'を使って1つの撮影でそれらをすべてコンパイルしないのですから。 – Aria
'Read()'を2回呼び出すため、うまくいけば1行おきにしか行かないでしょう。 – Crowcoder