注册 登录
编程论坛 ASP.NET技术论坛

ConnectionString 属性尚未初始化。

wushanshan1 发布于 2013-04-16 09:46, 938 次点击
程序代码:
protected void Button1_Click1(object sender, EventArgs e)
    {
      
        string str = "insert into zxly (name,comname,phone,email,add,title,content) values ('" + name.Text + "','" + comname.Text + "','" + phone.Text + "','" + email.Text + "','" + add.Text + "','" + title.Text + "','" + content.Text + "')";
        OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString());
        cn.Open();
        OleDbCommand com = new OleDbCommand(str, cn);
        cn.Close();
      
    }

这是什么原因啊,有没有人知道的,求大神解答。
2 回复
#2
yms1232013-04-20 10:32
程序代码:
protected void Button1_Click1(object sender, EventArgs e)
    {
      
        string str = "insert into zxly (name,comname,phone,email,add,title,content) values ('" + name.Text + "','" + comname.Text + "','" + phone.Text + "','" + email.Text + "','" + add.Text + "','" + title.Text + "','" + content.Text + "')";
        OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString());
        cn.ConnectionString=System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString();
        cn.Open();
        OleDbCommand com = new OleDbCommand(str, cn);
        cn.Close();
      
    }
#3
Aviva_Wang2013-04-20 20:45
System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()
你确定你在配置文件中有配置吗?
1