.sdf ファイルを winform に接続しようとしています。これが私がやろうとしていることです:
SqlConnection con = new SqlConnection();
con.ConnectionString=@"Data Source=D:\TestWinform\MyDB.sdf;Persist Security Info=True";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into User(Name) values('" + txt.Text + "')";
cmd.Connection = con;
con.Open(); // giving exception in this line
cmd.ExecuteNonQuery();
con.Close();
しかし、私はcon.Open()
この例外を与えることで問題に直面しています
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)
どうすればいいですか、ファイルが見つからなかったと思いますが、.sdf ファイルはその場所にあります。