using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace CodeConSql
{
public partial class Form1 : Form
{
SqlConnection Con = new SqlConnection("data source=local;Integrated security=SSPI;Initial Catalog=StudentSys;password=sasa");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Display();
}
private void Display()
{
string strsql = "select * from tblStudent";
SqlDataAdapter Da = new SqlDataAdapter(strsql, Con);
DataSet ds = new DataSet();
Da.Fill(ds, "tblstudent");
dataGridView1.DataSource = ds.Tables[0];
}
}
}
代码如上
理想结果是在bindingNavigator1里面显示数据库的字段
但是我把这个代码在同学的电脑却可以运行,他是sql2012,我想问的是:sql2016连接数据库的代码不一样吗?