快来帮帮!!!ConnectionString 属性尚未初始化怎么解决!!!!
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.We...
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class 注册会员_zhucehuiyuan : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection ConnectionString = new SqlConnection();
//SqlConnection conn = new SqlConnection(constring);
//SqlCommand cmd = new SqlCommand(str, conn);
//conn.Open();
string un = this.TextBox1.Text.ToString();
string mm =this.TextBox2.ToString();
string cp = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox3.Text.ToString(), "MD5");
SqlConnection ts = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ts"]);
ts.Open();
SqlCommand sd = new SqlCommand("select count(*) from 会员信息 where 姓名='" + un + "'", ts);
//0
int count = Convert.ToInt32(sd.ExecuteScalar());
if (count > 0)
{
Response.Write("<script>alert('用户名已存在');history.back()</script>");
}
else
{
SqlCommand intable = new SqlCommand("insert into 会员信息(姓名,性别,密码)values('" + un + "','" + mm + "','" + cp + "')", ts);
intable.ExecuteNonQuery();
Response.Write("<script language = javascript>alert('新建用户成功,请记住您的密码!')</script>");
}
}
}
运行提示ConnectionString 属性尚未初始化,怎么解决呢?在线等! 展开
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class 注册会员_zhucehuiyuan : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection ConnectionString = new SqlConnection();
//SqlConnection conn = new SqlConnection(constring);
//SqlCommand cmd = new SqlCommand(str, conn);
//conn.Open();
string un = this.TextBox1.Text.ToString();
string mm =this.TextBox2.ToString();
string cp = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox3.Text.ToString(), "MD5");
SqlConnection ts = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ts"]);
ts.Open();
SqlCommand sd = new SqlCommand("select count(*) from 会员信息 where 姓名='" + un + "'", ts);
//0
int count = Convert.ToInt32(sd.ExecuteScalar());
if (count > 0)
{
Response.Write("<script>alert('用户名已存在');history.back()</script>");
}
else
{
SqlCommand intable = new SqlCommand("insert into 会员信息(姓名,性别,密码)values('" + un + "','" + mm + "','" + cp + "')", ts);
intable.ExecuteNonQuery();
Response.Write("<script language = javascript>alert('新建用户成功,请记住您的密码!')</script>");
}
}
}
运行提示ConnectionString 属性尚未初始化,怎么解决呢?在线等! 展开
3个回答
展开全部
SqlConnection ConnectionString = new SqlConnection();
后面括号里面没东西,不报错才怪,括号里面是连接数据库的语句啊,密码,用户名,数据库等等
后面括号里面没东西,不报错才怪,括号里面是连接数据库的语句啊,密码,用户名,数据库等等
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
需要连接数据库的字符串
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询