新手求助,,!!!winform程序调试老是 sa用户登陆失败!!!咋回事

wukong0623 2008-07-12 11:38:46
我的机子xp sp2
我调试的winform程序是 c#2.0+sql2000
第一步 调试 用户登陆时

提示 : 用户"sa" 登陆失败

详细信息 :


有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.SqlClient.SqlConnection.Open()
在 MrCy.frmLogin.btnSubmit_Click(Object sender, EventArgs e) 位置 E:\new\MrCy\MrCy\frmLogin.cs:行号 49
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** 已加载的程序集 **************
mscorlib
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
MrCy
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
基本代码: file:///H:/在家下载/只是教程/asp.net%20c%23/net2.0教程2/书里代码教程/C%23项目开发全程实录%200806的书/06餐饮管理系统/MrCy/MrCy/bin/Debug/MrCy.exe
----------------------------------------
System.Windows.Forms
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
mscorlib.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------

************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。

例如:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

启用 JIT 调试后,任何无法处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。


各位 老大 这是咋回事!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
...全文
352 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
wheeler 2008-07-13
  • 打赏
  • 举报
回复
是什么数据库?

MS SQLSERVER?


@"Data Source=.;Initial Catalog=db_MrCy;Persist Security Info=False;User ID=sa;Password=123456"
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 panwen516 的回复:]
你把那部分相关的代码发上来看看呀,你这样说我们怎么知道呢?
[/Quote]

下面是 frmlogin.cs 代码
在 MrCy.frmLogin.btnSubmit_Click(Object sender, EventArgs e) 位置 E:\new\MrCy\MrCy\frmLogin.cs:行号 49

?????? 问题是 frmLogin.cs 这个文件 根本不在 e盘,我晕来,系统出错后提示怎么在 E盘呢

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MrCy
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}



private void Form1_Load(object sender, EventArgs e)
{
txtName.Focus();
}


private void txtPwd_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
btnSubmit_Click(sender, e);
}
}

private void btnSubmit_Click(object sender, EventArgs e)
{
if (txtName.Text == "")
{
MessageBox.Show("请输入用户名", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
if (txtPwd.Text == "")
{
MessageBox.Show("请输入密码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
SqlConnection conn = BaseClass.DBConn.CyCon();
conn.Open();
SqlCommand cmd = new SqlCommand("select count(*) from tb_User where UserName='" + txtName.Text + "' and UserPwd='" + txtPwd.Text + "'", conn);
int i = Convert.ToInt32(cmd.ExecuteScalar());
if (i > 0)
{
cmd = new SqlCommand("select * from tb_User where UserName='" + txtName.Text + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
string UserPower = sdr["power"].ToString().Trim();
conn.Close();
frmMain main = new frmMain();
main.power = UserPower;
main.Names = txtName.Text;
main.Times = DateTime.Now.ToShortDateString();
main.Show();
this.Hide();
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
}
}

private void btnConcel_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定退出系统吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
{
Application.Exit();
}
}
}
}


--------------------------------------

下面是 数据库连接文件代码


DBConn.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace MrCy.BaseClass
{
class DBConn
{
public static SqlConnection CyCon()
{
return new SqlConnection("server=.;database=db_MrCy;uid=sa;pwd=123456");
}
}
}
panwen516 2008-07-12
  • 打赏
  • 举报
回复
你把那部分相关的代码发上来看看呀,你这样说我们怎么知道呢?
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 xs8577 的回复:]
你的连接字符串是直接写在New SqlConnection(...)里面么? 还是把字符串赋值给sting,再把sting丢到构造参数里面的?
我估计你把丢在webconfig里面的字符串没改就直接拿来Winform用了
[/Quote]

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace MrCy.BaseClass
{
class DBConn
{
public static SqlConnection CyCon()
{
return new SqlConnection("server=.;database=db_MrCy;uid=sa;pwd=123456");
}
}
}

没有啊 兄弟
我这样的啊
xs8577 2008-07-12
  • 打赏
  • 举报
回复
你的连接字符串是直接写在New SqlConnection(...)里面么? 还是把字符串赋值给sting,再把sting丢到构造参数里面的?
我估计你把丢在webconfig里面的字符串没改就直接拿来Winform用了
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 asdf311 的回复:]

在 System.Data.SqlClient.SqlConnection.Open()
在 MrCy.frmLogin.btnSubmit_Click(Object sender, EventArgs e) 位置 E:\new\MrCy\MrCy\frmLogin.cs:行号 49

你的Sql连接字符串写错了!sa的密码不正确。
[/Quote]

我是本机调试的
我调试 asp.net的 网站程序时 一样的密码 很正常 没出错的
但调试这个 winform程序时就出错
amandag 2008-07-12
  • 打赏
  • 举报
回复
确认sa能在SQL Server中登录成功
wheeler 2008-07-12
  • 打赏
  • 举报
回复

在 System.Data.SqlClient.SqlConnection.Open()
在 MrCy.frmLogin.btnSubmit_Click(Object sender, EventArgs e) 位置 E:\new\MrCy\MrCy\frmLogin.cs:行号 49

你的Sql连接字符串写错了!sa的密码不正确。
hztltgg 2008-07-12
  • 打赏
  • 举报
回复
确定sa能登陆先?手工登录一下看看
wcbenben 2008-07-12
  • 打赏
  • 举报
回复
用户 密码对不对啊?
换WINDOWS连接试试!
还有如果访问远程数据库,看看防护墙有没有问题!
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
咋没人哪
myh0305 2008-07-12
  • 打赏
  • 举报
回复
http://www.connectionstrings.com/
参考这个网站上的数据库连接方式吧
这个报错, 肯定是数据库连接字符串不正确
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 billclinton8 的回复:]
你把你的连接字符串贴出来
[/Quote]

下面是 数据库连接文件代码


DBConn.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace MrCy.BaseClass
{
class DBConn
{
public static SqlConnection CyCon()
{
return new SqlConnection("server=.;database=db_MrCy;uid=sa;pwd=123456");
}
}
}
billclinton8 2008-07-12
  • 打赏
  • 举报
回复
你把你的连接字符串贴出来
wukong0623 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 greenery 的回复:]
SqlConnection conn = BaseClass.DBConn.CyCon();
你这里的获取连接,里面的连接字符串对吗?
1 指向那个数据库? 是指向那个 数据库
2 sa 密码是否正确? 密码是 正确的 123456
3 数据库服务器是否启用了 Sql 与 Window 混合身份验证模式? 是的已经启用
[/Quote]


还是一样的错误提示
?????????????????????????
greenery 2008-07-12
  • 打赏
  • 举报
回复
SqlConnection conn = BaseClass.DBConn.CyCon();
你这里的获取连接,里面的连接字符串对吗?
1 指向那个数据库?
2 sa 密码是否正确?
3 数据库服务器是否启用了 Sql 与 Window 混合身份验证模式?
xiaoqiuwyh 2008-07-12
  • 打赏
  • 举报
回复
看下sql的登录方式
老田低代码 2008-07-12
  • 打赏
  • 举报
回复
你可以使用查询分析器连接看看,sa登陆失败一定是密码问题,绝对不可能是什么防火墙问题,绝对。。。。如果是防火墙问题那应该是说数据库不存在或者拒绝访问之类的。

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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