我正在制作一个程序,想从一个邮件中发送数据库中的多个用户的邮件,但我收到一个错误信息,即
对象引用没有被设置为一个对象的实例。
这是连接DB的代码。
SqlCommand cmd = null;
// Error occurs on the line below
string connectionString = (ConfigurationManager.ConnectionStrings["SchedulingInterviewsConnectionString"].ConnectionString);
string queryString = @"SELECT Email FROM interview WHERE Email = Email";
using (SqlConnection connection =
new SqlConnection(connectionString))
{
SqlCommand command =
new SqlCommand(queryString, connection);
connection.Open();
cmd = new SqlCommand(queryString);
cmd.Connection = connection;
SqlDataReader reader = cmd.ExecuteReader
你可以检查如下:(ConfigurationManager.ConnectionStrings["SchedulingInterviewsConnectionString"]= null)
你需要添加'SchedulingInterviewsConnectionString'的连接字符串。