如何在configuration manager中创建示例

yfjy0ee7  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(334)

我正在编写一个程序,从一封邮件发送数据库中的多封用户邮件,但我得到一个错误
对象引用未设置为对象的示例。
下面是连接到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
ijxebb2r

ijxebb2r1#

您可以按如下方式进行检查:(configurationmanager.connectionstrings[“schedulinginterviewsconnectionstring”]=null
您需要添加'schedulinginterviewsconnectionstring'的connectionstring

相关问题