我正在寫一個方法來查詢一個表並返回一個包含指定列的對象數據集。此外,我的用戶名&密碼有問題,所以我正在使用Windows身份驗證,但我不太清楚在我寫到現在的代碼段中。在方法中返回一個數據集作爲對象
protected void GetProgramList()
{
SqlConnection cn = new SqlConnection("server=Daffodils-PC/sqlexpress;Database=Assignment1;Trusted_Connection=Yes;");
SqlCommand cmd = new SqlCommand("SELECT ProgramName FROM Program", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet1 ds1 = new DataSet1();
}
我一直在試圖遵循MS官方文檔,但我不確定我要去哪裏?有人可以幫助我一些鏈接或片段?
你在找什麼在這裏解釋。 http://stackoverflow.com/questions/6073382/read-sql-table-into-c-sharp-datatable – test 2012-07-22 06:07:49
感謝您的鏈接! – unknownsatan 2012-07-22 06:09:11