내 오류 : 테이블 chang9가 이미 있습니다.sqlite 테이블을 C에서 이미 삭제 한 후 삭제하는 방법 #
이sqlite_cmd.CommandText = " DROP Table 'chang9'";
아마와 구문에 문제가있다 : 그래서 내가 (운으로) 사용,
나는 주위에 인터넷 검색, 사람들은 당신이 그것을 실행 한 후 테이블을 삭제한다고? 그러나 여기 내 전체 코드는 다음과 같습니다 :
private void button4_Click(object sender, EventArgs e)
{
// We use these three SQLite objects:
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
// create a new database connection: // Maybe error here - video was different
sqlite_conn = new SQLiteConnection(@"Data Source=database.db;Version=3;");
// open the connection:
sqlite_conn.Open();
// create a new SQL command:
sqlite_cmd = sqlite_conn.CreateCommand();
// Let the SQLiteCommand object know our SQL-Query:
sqlite_cmd.CommandText = "CREATE TABLE chang9 (Seq text, Field text, Desc text, Len text, Dec text, Typ text, Percnt text, Pop text, Alzero text, MaxLen text);";
// Now lets execute the SQL
sqlite_cmd.ExecuteNonQuery();
sqlite_cmd.CommandText = "INSERT INTO chang9 (Seq, Field, Desc, Len, Dec, Typ, Percnt, Pop, Alzero, MaxLen) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)";
sqlite_cmd.Parameters.AddWithValue("@p1", 6); // dummy initial values
sqlite_cmd.Parameters.AddWithValue("@p2", 878);
sqlite_cmd.Parameters.AddWithValue("@p3", 56);
sqlite_cmd.Parameters.AddWithValue("@p4", 6);
sqlite_cmd.Parameters.AddWithValue("@p5", 546);
sqlite_cmd.Parameters.AddWithValue("@p6", 565);
sqlite_cmd.Parameters.AddWithValue("@p7", 568);
sqlite_cmd.Parameters.AddWithValue("@p8", 526);
sqlite_cmd.Parameters.AddWithValue("@p9", 586);
sqlite_cmd.Parameters.AddWithValue("@p10", 526);
for (int i = 0; i < 500 ; i+= 10) // Filling SQlite table rows and columns with values from our list
{
sqlite_cmd.Parameters.AddWithValue("@p1", list[i]);
sqlite_cmd.Parameters.AddWithValue("@p2", list[i+1]);
sqlite_cmd.Parameters.AddWithValue("@p3", list[i + 2]);
sqlite_cmd.Parameters.AddWithValue("@p4", list[i + 3]);
sqlite_cmd.Parameters.AddWithValue("@p5", list[i + 4]);
if (i > 490)
break;
sqlite_cmd.Parameters.AddWithValue("@p6", list[i + 5]);
sqlite_cmd.Parameters.AddWithValue("@p7", list[i + 6]);
sqlite_cmd.Parameters.AddWithValue("@p8", list[i + 7]);
sqlite_cmd.Parameters.AddWithValue("@p9", list[i + 8]);
sqlite_cmd.Parameters.AddWithValue("@p10", list[i + 9]);
sqlite_cmd.ExecuteNonQuery();
}
sqlite_cmd.CommandText = " DROP Table 'chang9'";
sqlite_conn.Close();
}
안녕하세요, pls 님이 bunyip의 답변에 게시 된 의견을 참조하십시오. 테이블을 생성하지 않고이 테이블을 단순히 어떻게 볼 수 있습니까? 난 그냥 여러 번 프로그램을 실행하고 같은 테이블을 반복해서 볼 수 있어야합니다. – user2788405