c#程序问题各位大哥帮帮看下 --我 才学习的 看吧 懂~~~~

来源:百度知道 编辑:UC知道 时间:2024/07/05 02:10:05
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private DataSet ds = new DataSet();
private System.Data.SqlClient.SqlConnection conn = null;
private System.Data.SqlClient.SqlDataAdapter da = null;
private const string DRIVER = "server=.;database=northwind;uid=sa;pwd=sa";
private const string sql_select = "select * from region";

private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection(DRIVER);
da = new SqlDataAdapter(sql_select,conn);

对数据库操作需要using System.Data; 空间,而如果对SQL操作的话就要,using System.Data.SqlClient; 空间,其他一有OLEDB空间,OLEDB数据源连接数据库的命名空间。

缺少引用
加一个
using System.Data.SqlClient;

少了个引用啊,在最上面加上
using System.Data.SqlClient;

我建议你可以直接在命名空间里引用一个using System Data.Sql;

命名空间少了一个 在
using system data下面加上
using system data.sqlclient;

恩 同意以上的回答 ...其实你直接百度就可以得到 呵呵..