Sets the DataSource of a DataGrid
'Assembly: System.Windows.Forms.dll
'Assembly: System.Data.dll
'Assembly: System.Data.SqlServerCe.dll
'Assembly: System.Xml
'Namespace: Microsoft.VisualBasic
'Namespace: System.Windows.Forms
'Namespace: System.Data
'Namespace: System.Data.SqlServerCe
'Dim datagrid AS DataGrid
Private Sub SetDataSource()
Dim sqlConn As System.Data.SqlServerCe.SqlCeConnection
Dim sqlDS As New DataSet
' It is assumed that there is a SQL Server Mobile Edition database
' named test.sdf, and that the database has a table named
' People. These should be modified to fit your application.
sqlConn = New SqlCeConnection(DataSourceName)
' Select everything from a database named People on the SqlCeConnection sqlConn.
Dim sqlDA As New SqlCeDataAdapter(string, sqlConn)
' Fill the DataTable People within the DataSet sqlDS.
sqlDA.Fill(sqlDS, table)
' Set the DataSource as the People table in the DataSet.
datagrid.DataSource = sqlDS.Tables(table)
End Sub