winCE连接pc上的sql server2000,报错
winCE上的应用程序连接pc机上的sql server,将数据库中的一个表显示出来,报告错误:sql server does not exist or acess denied。但新建WindowsForm项目下测试正常
代码:
string CONN_STRING_REMOTE = "database=Northwind;server=服务器ip;User Id=xxx;Password=xxx;";
string SELECT_Products = "select * from Products";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = CONN_STRING_REMOTE;
SqlCommand comm = new SqlCommand();
comm.CommandType = CommandType.Text;
comm.CommandText = SELECT_Products;
comm.Connection = conn;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
DataTable dt = new DataTable();
try
{
da.Fill(dt);
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
dataGrid1.DataSource = dt;
大哥们帮忙看下,小弟谢过了!