读者朋友:
您好,用下面这种形式试一下:
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=C:\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\Samples\\Northwind.sdf");
sqlceCon.Open();
SqlCeDataAdapter adptrOdbc = new SqlCeDataAdapter("select * from customers", sqlceCon);
adptrOdbc.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}