C#連接SQLServer數據庫,運行正確,但是不出結果,代碼如下
string conn, sql;
conn = "Server=.;Database=13rj;Trusted_Connection=SSPI";//13rj是數據庫名稱
sql = "select * from 13rj_basic";//13rj_basic是表名稱
SqlConnection myconn = new SqlConnection(conn);
myconn.Open();
SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
DataSet myds = new DataSet();
myda.Fill(myds, "13rj_basic");
dataGridView1.DataSource = myds.Tables["13rj_basic"];
檢查你連接的各個參數,估計還是有問題。