我想与我的伙伴关系中的服务器契约4.0联系起来。 NET应用软件。
守则的例子如下:
protected void Page_Load(object sender, EventArgs e)
{
string connStr = "Data Source=D:\MyDB.sdf;";
string sqlStr = "select * from tblMyTable";
var sqlDataSrc = new SqlDataSource(connStr, sqlStr);
GridWithUrls.DataSource = sqlDataSrc;
GridWithUrls.DataBind();
}
But I have the next error: "A network-related or instance-specific error occurred while establishing a connection to SQL Server.The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"
The SqlDataSource has constructor with three parameters, one of them is providerName so, how to specify that I want definitely use Sql Server Compact provider ? Also I have added System.Data.SqlServerCe reference..