平顶山哪里有卖烟花:c#菜菜问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 01:25:24
那位大虾能给我提供一段代码?让我学习学习
用VS 建立一个项目(windows应用程序) 满足以下供能就可以了
运行时可以显示一个数据库的所有字段值
也就是说在 form_load 中添加一段连接数据库代码
private void Form1_Load(object sender, EventArgs e)
{
string strConnect =@" Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+ StartupPath (@"\kmhh\datalsrbb.mdb") ;
OleDbConnection aConnection = new OleDbConnection ( strConnect ) ;
string sql = "select * from table TAB_fh";
Oledbcommand cmd = new oledbcommand(sql, components);
ConnectionState.Open();
this.dataGridView1.DataSource = cmd.executereader();
this.dataGridView1.DataBindingComplete();
ConnectionState.Closed();
老出错没办法了
大虾帮帮忙 写个正确的我学习学习 谢谢了
对了 下面是我的空间声明
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
在线等

去CSDN 吧
偶不会C#了

少了
Using System.Data.OleDB;