wince下引用sqlclient.dll
增加dbnetlib.dll
便可以随意操作远程数据库
dbnetlib.dll下载地址:http://download.csdn.net/detail/tiz198183/4344983
1、将 dbnetlib.dll 复制粘贴到vs项目里面
2、设置dbnetlib.dll的属性-----》复制到输出目录:如果较新则复制
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlTypes; using System.Data.SqlClient; namespace Wince远程连接数据库 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string Sqlstr = "Data Source=192.168.1.225;Database=MyOffice;User ID=sa;Password=123"; System.Data.SqlClient.SqlConnection conn= new SqlConnection(Sqlstr); System.Data.SqlClient.SqlCommand cmd = new SqlCommand("select * from UserInfo",conn); conn.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dataGrid1.DataSource = dt; } } }
代码下载:http:/download.csdn.net/detail/anbylau2130/4735371
内含sqlclient,dbnetlib