您的位置:首页 > 编程语言

典型代码-.net连接access(窗体)

2016-02-02 16:44 330 查看
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;

using System.Data.OleDb;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DataBase\\xxx.mdb");     

            OleDbDataAdapter da = new OleDbDataAdapter("select * from info", conn);            

             DataSet ds = new DataSet();        

             conn.Open();

     da.Fill(ds);

          conn.Close();

            dataGridView1.DataSource = ds.Tables[0];

 

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# access