Dataset not displayed in grid

Oct 19 2004 7:59 PM
I've created a test application to display data in a datagrid using a sqldataadapter and using a dataset. However, no data shows in the datagrid. However, If I change to the Pubs database and select * from authors doing everything else the same - the data shows up in the grid. Help please! Created a new database on my (local) SQL Server 2000 - named junk. Created 1 table in junk named Table1. Added 2 varchar(10) columns to Table1. Added 2 records to Table1. Created new C# windows application called TestGrid. Added dataGrid1 to Form1. Added SqlDataAdapter1 Created new connection: Server name: LocalServer Used Windows NT Integrated Security Selected Database: junk Test Connection: Test connection succeeded. Use SQL statements: Select * from table1 Menu Item: Data/Generate Dataset New dataset: dsTable1 Table1 (sqlDataAdapter1) Menu Item: Data/Preview Dataset Select sqlDataAdapter1 Target dataset: TestGrid.dsTable1 Fill Dataset shows the correct data. dataGrid1 properties DataSource: dsTable11 DataMember: Table1 Add Button: button1 Add button1_Click event private void button1_Click(object sender, System.EventArgs e) { try { dsTable1 dsMyData = new dsTable1(); sqlDataAdapter1.Fill(dsMyData); MessageBox.Show ("Grid should display data."); } catch (Exception ex) { MessageBox.Show (ex.Message); } } Click the button - no errors and no data is displayed in the grid. The message box that displays "Grid should display data." shows up with no problem. It has to be something simple I'm overlooking. Any help would be appreciated.

Answers (2)