Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem with Datagrid

Problem with Datagrid

Scheduled Pinned Locked Moved C#
databasehelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yueru
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • Y yueru

      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

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      Y 1 Reply Last reply
      0
      • M Mycroft Holmes

        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

        Y Offline
        Y Offline
        yueru
        wrote on last edited by
        #3

        I've already tried It's still "no such table: par" And what the problem with the # in sql_cmd.ExecuteNonQuery();

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups