高分求解远程连接sql2000问题

wf20032723 wf20032723 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
小弟最近新写了一个程序,使用的是sql2000数据库,在本机上使用的时候,能够验证用户名和密码,从而登陆。但在另一台电脑上,登陆的时候,老是弹出:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
我想请问下是怎么回事?
我对sql2000打了sp4补丁,使用netstat -na命令,看到1433端口已经在监听。安装sql2000的IP:91.52.48.4,远程计算机IP:91.52.48.176,这2台电脑能ping通。

sql2000使用的是windows登陆验证,密码为空。
连接数据库代码:
this.sqlConnection1.ConnectionString = "workstation id=91.52.48.4,1433;packet size=4096;integrated security=SSPI;datasource=91.52.48.4,1433;persist security info=True;initial catalog=wf";

wf是我的sql2000数据库名称

代码不多,只是一个简单的密码验证,请各位高手帮我看看到底是怎么回事:

代码如下:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace 毕业设计
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)//处理登陆
{
try
{
string StrSQL="SELECT * FROM 密码管理表 WHERE 用户名 LIKE '"+this.textBox1.Text+"' AND 用户类
型 LIKE '"+this.comboBox1.Text+"'";//this.textBox1.Text里面是用户名,this.comboBox1.Text是用户类型,

this.sqlDataAdapter1.SelectCommand.CommandText=StrSQL;
this.sqlDataAdapter1.SelectCommand.Connection=this.sqlConnection1;
//打开数据库连接
this.sqlConnection1.Open();
//执行SQL命令
System.Data.SqlClient.SqlDataReader MyRead=this.sqlDataAdapter1.SelectCommand.ExecuteReader();


while(MyRead.Read())
{

if(MyRead.GetString(2).Trim()==this.textBox2.Text.ToString())//如果密码相同
{
Form4 dlg4=new Form4();
if(this.comboBox1.Text=="系统管理员")
{
dlg4.type=1;
}

if(this.comboBox1.Text=="业务员")
{
dlg4.type=2;
}
if(this.comboBox1.Text=="普通用户")
{
dlg4.type=3;
}
dlg4.ShowDialog();
}
else
{
MessageBox.Show("您所输入的用户或密码有错误","信息提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}

this.sqlConnection1.Close();
}
catch(Exception Err)
{
MessageBox.Show(Err.Message,"信息提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
//如果打开了连接,则关闭它
if(this.sqlConnection1.State==ConnectionState.Open)
{
this.sqlConnection1.Close();
}
}
}

private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}


...全文

相关推荐

评论 16
收藏 已收藏
分享
返回顶部
wf20032723
C# 111,129 成员 642,539 内容