当前位置: 代码迷 >> Sql Server >> 本地 asp怎么连接sql 2005 express数据库
  详细解决方案

本地 asp怎么连接sql 2005 express数据库

热度:401   发布时间:2016-04-27 11:54:18.0
本地 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");

  相关解决方案