我有一个与我的网站连接的名为Sort.sdf
的SQL Compact数据库,其中包含一个名为“sort”的表。我需要将表中所有记录导出到XML文件,但我一直遇到以下错误,无法找到解决方法:
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: Named
Pipes Provider, error: 40 - Could not open a connection to
SQL Server)
我已经使用相同的连接成功地向数据库中插入了数据,所以我认为那里没有问题。
SqlCeConnection conn = new SqlCeConnection("Data Source=|DataDirectory|Sort.sdf");
conn.Open();
DataSet ds = new DataSet();
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("Select * from Sort", conn.ConnectionString);
da.Fill(ds); //error on this line
ds.WriteXml(@"c:\temp\output.xml", XmlWriteMode.WriteSchema);
conn
。 - H H