SQLiteConnection sqliteconn = new SQLiteConnection();
            SQLiteConnectionStringBuilder sqlitestr = new SQLiteConnectionStringBuilder();
            sqlitestr.DataSource = "eroda";
            sqliteconn.ConnectionString = sqlitestr.ToString();
            sqliteconn.Open();
            SQLiteCommand cmd = new SQLiteCommand();
           
            string sqltext = "SELECT   SUM(product_number) AS num FROM order_list";
            cmd.CommandText = sqltext;
            
            //执行到这句程序就自动关闭了,没有错误提示。
            SQLiteDataReader dr = cmd.ExecuteReader();
            
            while (dr.Read())
            {
                string a = dr.GetString(0);
                MessageBox.Show(a);
            }
            sqliteconn.Close();搞了一天都不明白是怎么回事,请高手指教

解决方案 »

  1.   

    不出错才有鬼。
    SQLiteCommand cmd = new SQLiteCommand();
    cmd.CommandText = sqltext;
                
                //执行到这句程序就自动关闭了,没有错误提示。
                SQLiteDataReader dr = cmd.ExecuteReader();从头到尾,你的cmd就没有跟sqliteconn有过任何关系,一个空的SQLiteCommand 你read啥呀?
      

  2.   

    不好意思,贴漏了,不过不是这个问题dr.GetValue(0).ToString();
    这样才行