我觉得自己像个彻头彻尾的白痴。我一直在尝试连接到我创建了几个小时的数据库,但似乎无法连接。这是我的代码。
string chooseMoodCmbBx = moodCmbBx.SelectedIndex.ToString();
string source = "Data Source='E:\\Documents\\Database\\MyDatabase.sdf';" +
"Password='password';" +
"Persist Security Info=False;";
SqlConnection conn = new SqlConnection(source);
try
{
conn.Open();
MessageBox.Show("Succesfully Connected");
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString());
}