我在VS 2013中面临以下问题
System.Data.dll中出现未处理的“System.Data.SqlClient.SqlException”类型异常
以下是代码:
SqlConnection myConnection = new SqlConnection("Data Source =.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database1.mdf; Integrated Security = True; User Instance = True;");
myConnection.Open();
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = "SELECT * FROM Customer";
SqlDataAdapter myDataAdapter = new SqlDataAdapter(myCommand);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);
myConnection.Close();
foreach(DataRow myRow in myDataSet.Tables[0].Rows)
{
Console.WriteLine(myRow["FirstName"]+" " +myRow["LastName"]);
}
Console.ReadLine();