提示这句 da.Fill(ds); ConnectionString 属性尚未初始化。源码如下:
不知道是不是配置文件有错误,小弟不知道如何写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.OleDb;
using System.Configuration;
namespace 数据
{
public partial class Form1 : Form
{
OleDbConnection conn = new OleDbConnection(ConfigurationSettings.AppSettings["conn"]);
OleDbConnection conn1 = new OleDbConnection(ConfigurationSettings.AppSettings["conn1"]);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("select * from grxx", conn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
} --------------------编程问答-------------------- 先conn.Open --------------------编程问答-------------------- 提示还是这句啊、、不是配置文件中的问题啊 --------------------编程问答-------------------- 也有可能,看看你的配置文件里面写的对不对 --------------------编程问答-------------------- 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.OleDb;
using System.Configuration;
namespace 数据
{
public partial class Form1 : Form
{
OleDbConnection conn;
OleDbConnection conn1 = new OleDbConnection(ConfigurationSettings.AppSettings["conn1"]);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
conn = new OleDbConnection(ConfigurationSettings.AppSettings["conn"]);
OleDbDataAdapter da = new OleDbDataAdapter("select * from grxx", conn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
} --------------------编程问答-------------------- 不用open()也可以了
补充:.NET技术 , C#