“System.Data.SqlClient.SqlParameterCollection.Add(string, object)”已过时: 如何解决,求高手帮帮! 5
//创建数据连接stringsql="selectcount(*)fromuserswhereusername=@usernameandpassword=@passwor...
//创建数据连接
string sql = "select count(*) from users where username=@username and password=@password";
String strConn = "Data Source =.\\sqlexpress; Initial Catalog = Forum;integrated security=SSPI";
SqlConnection conn = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@username", username);
cmd.Parameters.Add("@password",password);
conn.Open();
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
//this.Hide();//隐藏当前页
Index shouye=new Index(username);
textBox1.Text = "";
textBox2.Text = "";
shouye.ShowDialog();
//Application.Run(shouye);
//MessageBox.Show("成功登陆");
//new Form2().InitializeComponent();
} 展开
string sql = "select count(*) from users where username=@username and password=@password";
String strConn = "Data Source =.\\sqlexpress; Initial Catalog = Forum;integrated security=SSPI";
SqlConnection conn = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@username", username);
cmd.Parameters.Add("@password",password);
conn.Open();
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
//this.Hide();//隐藏当前页
Index shouye=new Index(username);
textBox1.Text = "";
textBox2.Text = "";
shouye.ShowDialog();
//Application.Run(shouye);
//MessageBox.Show("成功登陆");
//new Form2().InitializeComponent();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询