首先需要添加using System.Data.SqlServerCe; 引用,sdf属于SQL Server CE版本

 SqlCeConnection cc = new SqlCeConnection();
        DataTable dt = new DataTable();
        private void button1_Click(object sender, EventArgs e)
        {
            cc = new SqlCeConnection("Data Source=Database1.sdf;password=123");
            cc.Open();
            SqlCeDataAdapter ada = new SqlCeDataAdapter("select * from aa", cc);
            ada.Fill(dt);

        }

如果sdf没设置密码可以将password去掉

相关文章:

  • 2022-12-23
  • 2021-06-09
  • 2021-11-04
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-25
  • 2021-12-02
  • 2021-12-15
  • 2022-12-23
  • 2021-06-12
  • 2022-02-27
相关资源
相似解决方案