silent-joker 2015-05-27 01:30 采纳率: 0%
浏览 3432

用C#写服务器程序连接本地SQL SERVER,该怎么写?

protected void ImageButton1_Click(object sender, EventArgs e)
{
string UserName = Request.Form["Username"].ToString().Trim();
string UserPwd = Request.Form["pwd"].ToString().Trim();
SqlConnection scon = dtcon.getcon();
scon.Open();
SqlCommand cmd = scon.CreateCommand();
cmd.CommandText = getStrSQL(this.DropDownList1.Text);
int count = Convert.ToInt32(cmd.ExecuteScalar());
scon.Close();
if (count > 0)
{
Session["UserName"] = UserName;
Session["UserName1"] = this.DropDownList1.Text;
int rankID = getRankID(this.DropDownList1.Text);
Response.Redirect("Admin/" + transfer(rankID));
}
else
{
MessageBox.Show(this.Page, "请正确输入!");
this.Username.Text = "";
this.pwd.Text = "";
MessageBox.SetFocus(this.Username, this.Page);
return;
}


  • 写回答

5条回答 默认 最新

  • 全栈极简 领域专家: 后端开发技术领域 2015-05-27 01:58
    关注
    评论

报告相同问题?