vb

评价:
5
(1用户)
private void FindFrmMainRecord()
        {
            int i = 0;
            string strsql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stkm.mdb;Persist Security Info=False";
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(strsql);
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                string sql = "select * from stk";
                OleDbCommand com = new OleDbCommand(sql, conn);
                OleDbDataReader read = com.ExecuteReader();
                try
                {
                    while (read.Read())
                    {
                        dataGridView1.Rows.Add();
                       // dataGridView1.Rows[i].Cells[0].Value = i + 1;//"ID""name"]
                        dataGridView1.Rows[i].Cells[0].Value = read[1];
                        dataGridView1.Rows[i].Cells[1].Value = read[3];
                        dataGridView1.Rows[i].Cells[2].Value = read[4];
                        i = i + 1;
                        
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

本文为原创文章,转载请注明出处!

注册并通过认证的用户才可以进行评价!

发表评论