We recently purchased and started using Visual Studio 2005. We are trying to create an application in Visual Basic that has a datagrid which displays data from a SQL select statement (dataset). In Visual Studio 2003 the code below works fine, with a datagrid (in 2003 it's called a datagrid, in 2005 a datagridview not sure if thats the difference?) however the same code does not populate the datagridview in 2005. We don't get any errors, just no results in the grid.
Dim cn As New SqlConnection("Data Source=TESTSVR;Initial Catalog=JDE_CRP;Persist Security Info=True;User ID=TEST;password=TEST")
' Create a new SqlDataAdapter and pass the SQL Statement
' and connection object
Dim da As SqlDataAdapter = New SqlDataAdapter _
("SELECT FIELD1, FIELD2 from TABLE", cn)
' Create a DataSet to hold the SqlDataAdapter data
Dim ds As DataSet = New DataSet("Test")
' Call the Fill method to load the DataSet
da.Fill(ds)
' Set the DataSource property of the grid
' to bind the data from the DataSet
DataGrid1.DataSource = ds
Start Free Trial