急!vs2005(C#)用户登录连接数据库的源代码
来源:百度知道 编辑:UC知道 时间:2024/08/20 07:22:22
这是一个实例 有不懂的问我
{
string QuerySql = "select * from tTea where tTea_name ='" + username.Text + "' and tTea_pwd='" + pwd.Text + "'";
bool flag = DB.Query(QuerySql);
if (flag)
{
string ip = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
string Editsql = "insert into tAdminLog(tAdmin_name,tAdminLog_time,tAdminLog_ip,tAdminLog_zhuangtai) values('" + username.Text + "','" + DateTime.Now + "','" + ip + "','成功')";
bool flag1 = DB.Edit(Editsql);
Session["username"] = username.Text.Trim();
SqlConnection con = DB.CreatConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from tTea where tTea_name ='"