-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsqlserver.cs
More file actions
15 lines (15 loc) · 480 Bytes
/
sqlserver.cs
File metadata and controls
15 lines (15 loc) · 480 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
http://blog.csdn.net/kkkkkxiaofei/article/details/7904569
*/
private void button1_Click(object sender, EventArgs e){
string con, sql;
con = "Server=.;Database=Exercise;Trusted_Connection=SSPI";
sql = "select * from lianxi";
SqlConnection mycon = new SqlConnection(con);
mycon.Open();
SqlDataAdapter myda = new SqlDataAdapter(sql, con);
DataSet myds = new DataSet();
myda.Fill(myds, "lianxi");
dataGridView1.DataSource = myds.Tables["lianxi"];
mycon.Close();
}