c# 连接本地的sdf数据库文件

来源:互联网 发布:淘宝直通车权重怎么看 编辑:程序博客网 时间:2024/06/04 00:38
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.SqlServerCe;namespace testc{    public partial class Form1 : Form    {        SqlCeConnection sqlceCon = new SqlCeConnection();        SqlCeCommand sqlCeCom = new SqlCeCommand();        DataTable dt = new DataTable();        public Form1()        {            InitializeComponent();        }        private void Form1_Load(object sender, EventArgs e)        {            sqlceCon = new SqlCeConnection("Data Source=D:\\test.sdf");            sqlceCon.Open();            SqlCeDataAdapter adptrOdbc = new SqlCeDataAdapter("select * from customers", sqlceCon);            adptrOdbc.Fill(dt);            dataGridView1.DataSource = dt;        }          }}

0 0
原创粉丝点击