Problem with Datagrid
-
It's said that "Don't have par(my table)" and alway have error with sql_cmd.ExecuteNonQuery(); coz my file have # it can't read # <pre> private SQLiteConnection sql_con; private SQLiteCommand sql_cmd; private SQLiteDataAdapter DB; private DataSet DS = new DataSet(); private DataTable DT = new DataTable(); private void SetConnection() { sql_con = new SQLiteConnection("Data Source=pare.db;Version=3;New=False;Compress=True;"); // sql_con = new SQLiteConnection("Data Source=pare.db;Version=3;New=True;Compress=True;"); if I want to create new database } private void ExecuteQuery(string txtQuery) { <big> sql_con.Open();</big> sql_cmd = sql_con.CreateCommand(); sql_cmd.CommandText = txtQuery; <big> sql_cmd.ExecuteNonQuery(); </big> sql_con.Close(); } </pre> <pre> private void LoadData() { sql_con.Open(); sql_cmd = sql_con.CreateCommand(); string CommandText = "select * from par"; DB = new SQLiteDataAdapter(CommandText, sql_con);//นำข้อมูลออกมา DS.Reset(); DB.Fill(DS);//นาม ข้อมูลปายส่ายนาย ดาต้าเซด DT = DS.Tables[0]; dataGridView1.DataSource = DT; sql_con.Close(); } private void button2_Click(object sender, EventArgs e) { SetConnection(); LoadData(); } </pre> It has error on the BIG :doh: NO MORE TEAR
-
It's said that "Don't have par(my table)" and alway have error with sql_cmd.ExecuteNonQuery(); coz my file have # it can't read # <pre> private SQLiteConnection sql_con; private SQLiteCommand sql_cmd; private SQLiteDataAdapter DB; private DataSet DS = new DataSet(); private DataTable DT = new DataTable(); private void SetConnection() { sql_con = new SQLiteConnection("Data Source=pare.db;Version=3;New=False;Compress=True;"); // sql_con = new SQLiteConnection("Data Source=pare.db;Version=3;New=True;Compress=True;"); if I want to create new database } private void ExecuteQuery(string txtQuery) { <big> sql_con.Open();</big> sql_cmd = sql_con.CreateCommand(); sql_cmd.CommandText = txtQuery; <big> sql_cmd.ExecuteNonQuery(); </big> sql_con.Close(); } </pre> <pre> private void LoadData() { sql_con.Open(); sql_cmd = sql_con.CreateCommand(); string CommandText = "select * from par"; DB = new SQLiteDataAdapter(CommandText, sql_con);//นำข้อมูลออกมา DS.Reset(); DB.Fill(DS);//นาม ข้อมูลปายส่ายนาย ดาต้าเซด DT = DS.Tables[0]; dataGridView1.DataSource = DT; sql_con.Close(); } private void button2_Click(object sender, EventArgs e) { SetConnection(); LoadData(); } </pre> It has error on the BIG :doh: NO MORE TEAR
indicates you have a problem with your connection string. Probably an invalid path for
pare.db
Try putting in the fully qualified path as this will be looking in the folder where the exe is created (debug).Never underestimate the power of human stupidity RAH
-
indicates you have a problem with your connection string. Probably an invalid path for
pare.db
Try putting in the fully qualified path as this will be looking in the folder where the exe is created (debug).Never underestimate the power of human stupidity RAH