Window 嵌入式 CE 连接与 SQL Compact in Visual Studio 2008
Window embedded CE connectivity with SQL Compact in Visual Studio 2008
Solution Explorer is shown in this imageHow can i connect with SQL Compact server database for window CE devices. I have tired it with a simple code.Window CE should connect to the SQL compact server but i am novice user for this technology .This is error on device
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Data.SqlServerCe;
namespace SQLCompactConnectivity
{
public partial class Form1 : Form
{
//public SqlCeConnection con = new SqlCeConnection(@"Data Source=C:\Users\Administrator\Documents\Users.sdf");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String query = "Select * from Instrument";
String conString = @"Data Source =\Program Files\SQLCompactConnectivity\Data\Music.sdf";
SqlCeConnection con = new SqlCeConnection(conString);
SqlCeCommand cmd = new SqlCeCommand(query, con);
con.Open();
try
{
SqlCeDataReader rdr = cmd.ExecuteReader();
try
{
while (rdr.Read())
{
this.label1.Text += string.Format("\r\n ID: {0} Name: {1}", rdr[0].ToString(), rdr[1].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
rdr.Close();
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
}
}
经过一番研发,我找到了这个问题的答案。错误意味着 DLL 与设备不兼容。 SQL Compact service pack 1 不支持这个。此问题的解决方案是 [安装 SQL Compact Service Pack 2]1 和 Visual Studio 2008。该文件位于 C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\System.Data.SqlServerCe.dll 。所以现在从引用中删除您以前的 System.Data.SqlServerCe.dll 并添加 service pack 2 DLL 文件,例如 System.Data.SqlServerCe.dll。我希望这对你们所有人都有效。
Solution Explorer is shown in this imageHow can i connect with SQL Compact server database for window CE devices. I have tired it with a simple code.Window CE should connect to the SQL compact server but i am novice user for this technology .This is error on device
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Data.SqlServerCe;
namespace SQLCompactConnectivity
{
public partial class Form1 : Form
{
//public SqlCeConnection con = new SqlCeConnection(@"Data Source=C:\Users\Administrator\Documents\Users.sdf");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String query = "Select * from Instrument";
String conString = @"Data Source =\Program Files\SQLCompactConnectivity\Data\Music.sdf";
SqlCeConnection con = new SqlCeConnection(conString);
SqlCeCommand cmd = new SqlCeCommand(query, con);
con.Open();
try
{
SqlCeDataReader rdr = cmd.ExecuteReader();
try
{
while (rdr.Read())
{
this.label1.Text += string.Format("\r\n ID: {0} Name: {1}", rdr[0].ToString(), rdr[1].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
rdr.Close();
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
}
}
经过一番研发,我找到了这个问题的答案。错误意味着 DLL 与设备不兼容。 SQL Compact service pack 1 不支持这个。此问题的解决方案是 [安装 SQL Compact Service Pack 2]1 和 Visual Studio 2008。该文件位于 C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\System.Data.SqlServerCe.dll 。所以现在从引用中删除您以前的 System.Data.SqlServerCe.dll 并添加 service pack 2 DLL 文件,例如 System.Data.SqlServerCe.dll。我希望这对你们所有人都有效。