WinForms 프로젝트에 설치 한 DataGridView가 있습니다. 열은 모두 디자이너 파일에 정의됩니다. 내 SQL을 실행하려면 DataGridView의 열이 쿼리의 열 이름으로 바뀝니다.미리 정의 된 열이있는 DataGridView에 대한 DataSet
DataGridView에서 정의한대로 열을 유지하고 데이터 집합의 행을 GridView에 추가하는 방법은 무엇입니까?
//Columns as they appear in the DataGridView
Name | Address | City | State | Zip | Account Num |
//Populate the gridView
DataSet ds = Account.search(strSearch);
accountGrid.DataSource = ds.Tables[0];
//query
string sql = "SELECT distinct acctNum, name, address, city, state, zip from accounts";
return DataService.GetDataSet(sql);
//The End Result of the columns
acctNum | name | address |city | state | zip