各位大佬紧急求救 小弟刚刚接触VS 十万火急呀
简单来说,你的sa密码验证失败。可能的原因是,你sql server没有启用混合验证或者没有启用sa帐户,或者你的密码错了,密码是区分大小写的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace _111
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = "Data Source=Ser2008-25;Database=EduBase1;Integrated Security=false;Uid=jsj;Password=2wsx@WSX";
sqlConnection.Open();
sqlConnection.Close();
}
}
}
也可以使用本地连接:
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString =
"Server=(local);Database=MZJJSFXT;Integrated Security=sspi";
sqlConnection.Open();
sqlConnection.Close();
两种连接方法都可以试用一下。希望可以帮助到你哦!