我正在使用 C# 和 SQL 學習 WinForms。當我執行代碼時出現此錯誤:“System.Data.dll 中出現類型為‘System.Data.SqlClient.SqlException’的未處理異?!边@是代碼:string connetionString; SqlConnection cnn; connetionString = @"Data Source=desktop-brvgrif\sqlexpress;Integrated Security=True"; cnn = new SqlConnection(connetionString); cnn.Open(); SqlCommand command; SqlDataReader dataReader; String sql, Output = ""; sql = "SELECT TutorialID,TutorialName from demotb"; command = new SqlCommand(sql, cnn); dataReader = command.ExecuteReader(); while(dataReader.Read()) { Output = Output + dataReader.GetValue(0) + " - " + dataReader.GetValue(1) + "\n"; } MessageBox.Show(Output); dataReader.Close(); command.Dispose(); cnn.Close();
SqlException 未處理 System.Data.dll 中發生類型
慕無忌1623718
2022-11-22 15:39:30