string str = "user id=sa;password=000;initial catalog=glxtSQL;Server=KEYJOB;Connect Timeout=60;";
SqlConnection conn = new SqlConnection(str);
conn.Open();
在.cs页面写一个数据库连接类
之后在页面怎么掉用帮忙写下
马上散分
SqlConnection conn = new SqlConnection(str);
conn.Open();
在.cs页面写一个数据库连接类
之后在页面怎么掉用帮忙写下
马上散分
解决方案 »
- 求助:如何设置Rdlc文本框的长度?
- 请问怎么禁止某个浏览器访问自己的网页,附代码哦~.net和js都可以
- vs 2005中web项目没有默认命名空间,我自己手动加了一个出错
- 如何设置treeview控件,让显示的时候是透明的?
- DotNet下的ASP页面设计
- 前辈们求帮忙 aspx页面调用dll的问题
- 怎样用存储过程:加一个@count参数来实现这样的功能,SELECT TOP @count
- 怎么样儿在页面中弹出一个只有确定按纽的对话框??没有那个取消,点确定后对话框关闭!急
- 晴问在asp.net里面,用类可以调用一个dll文件么?该怎么调用?
- 怎么打印DataGrid控件中的表,不用水晶报表能实现吗?
- 求asp.net.0中小型系统的案例,学习用!想借鉴一下开发模式!
- vs.net无法设置控件属性
SqlConnection conn = new SqlConnection(str);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from side where SideID=1";
cmd.Connection = con;
SqlDataReader dr=null;
try
{
dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Write(dr["SideLeft"].ToString());
}
}
catch (Exception ex)
{
// return ex;
}
就是这样才可以理解学习到东西哦
string strConnection = "user id=sa;password=123;";
strConnection += "initial catalog=glxtSQL;Server=KEYJOB;";
strConnection += "Connect Timeout=30";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
string sql = "select ausername,bpassword from adminvip where ausername='" + TextBox1.Text + "' or bpassword='" + TextBox2.Text + "'";
SqlCommand cmd = new SqlCommand(sql, objConnection);
SqlDataReader rs = cmd.ExecuteReader();
if (rs.Read())
{
if (rs.GetValue(0).ToString().Trim() == TextBox1.Text)
{
if (rs.GetValue(1).ToString().Trim() == TextBox2.Text)
{
Session["username"] = TextBox1.Text;
Response.Redirect("order.aspx");
}
else
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "密码不正确!";
}
}
else
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "您用户名不正确!";
}
}
else
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "帐号不存在!";
} }