帮忙看下,在 System.ArgumentException 中第一次偶然出现的“System.Data.dll”类型的异常
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 链接数据库
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("数据库不能为空");
}
else
{
try
{
//server=MRC-8CF94303A82\\MRNET;database=" + textBox1.Text.Trim() + ";uid=sa;pwd=111";
string sqlstr = "78N5FN4H3YXS3GZ;database=" + textBox1.Text.Trim() + ";uid=sa;pwd=****";
//\\MRNET:database=" + textBox1.Text.Trim() + ";uid=sa;pwd=forever1997+
SqlConnection conn = new SqlConnection(sqlstr);
conn.Open();
if (conn.State == ConnectionState.Open)
{
label2.Text = "连接"+textBox1.Text+"数据库成功";
}
}
catch
{
label2.Text = "连接"+textBox1.Text+"数据库失败";
}
}
}
}
}
上面是代码,目前怀疑我的sqlServer配置的问题,SQL的密码和账号没有错误,请教各位一下,这个问题运行可能出现一些的问题,和解决方案