用户 sa 登陆失败

mst_yang 2008-11-08 06:20:32
public partial class yanzheng : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string username = Request.Form["username"].ToString();
string userpassword = Request.Form.Get("userpassword").ToString();

SqlConnection con = new SqlConnection("server=.;database=text;uid=sa;pwd=fengqq6604;");
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from text where username ='" + username + "' and userpassword='" + userpassword + "'", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("loginFail.htm");
}
}
}
代码如上
用的VS2005 数据库是用SA登陆的 密码什么都确定 执行到con.Open();出现异常
请问问题出在哪里 具体该如何解决?
...全文
51 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
surpass63 2008-11-08
  • 打赏
  • 举报
回复
我装的微软的SQL2005 ! 没有出现过这样的问题!
代码没有问题!应该是你连接数据库服务器的时候出错了!
或权限的问题!
  • 打赏
  • 举报
回复
我用的是MS-sql没出现过这样的问题 只能说你这不是代码的问题
是数据库出问题了 因为没出过类似的问题具体我也不知道
mst_yang 2008-11-08
  • 打赏
  • 举报
回复
哦对了 忘记说明 我用的是万恶的SQL2005 T0T
mst_yang 2008-11-08
  • 打赏
  • 举报
回复
自己顶一下
另外请高人们提供个可靠的解决方法
请不要说采用混合登录模式之类的 试验过了 依然没有效果
更希望大家高抬贵手 别让我重装数据库……T0T
zhangzhicong 2008-11-08
  • 打赏
  • 举报
回复
SqlConnection con = new SqlConnection("server=服务器;database=text;user id=sa;pwd=fengqq6604;");
试试。
mst_yang 2008-11-08
  • 打赏
  • 举报
回复
肯定事连接服务器的时候出错了
那出现这种问题该从哪里开始解决啊?

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧