日期:2014-05-18  浏览次数:20609 次

本地 asp如何连接sql 2005 express数据库啊
本地 asp如何连接sql 2005 express数据库啊
连接代码如何写啊

------解决方案--------------------
你应该去ASP版问.
------解决方案--------------------
最简单的是ODBC 然后用ADO.net
------解决方案--------------------
一个完整的例子

string userName = Request.Form["userName"];

string userPwd = Request.Form["userPwd"];

SqlConnection con = new SqlConnection("server=localhost\\SqlExpress;uid=sa;pwd=123456;database=login");

con.Open();

SqlCommand cmd=new SqlCommand("select count(*) from login where userName='"+userName+"' and userPwd='"+userPwd+"'",con);

int count=Convert.ToInt32(cmd.ExecuteScalar());

if(count>0)

{
Response.Redirect("main.aspx");