In code, clear the DataSource property and reassign the ConnectionString property. In this example, we will change the connection string to the Northwind sample database and bind DataGrid to a C1ExpressTable control. Add the following code to your project (changing the connection string to add the full directory where the Nwind database is installed):
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
DataGrid1.DataSource = Nothing C1ExpressTable1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C1NWind.mdb" C1ExpressTable1.DbTableName = "Customers" C1ExpressTable1.ExpressConnection.Fill() DataGrid1.DataSource = C1ExpressTable1 |
To write code in C#
C# |
Copy Code
|
---|---|
DataGrid1.DataSource = null; C1ExpressTable1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C1NWind.mdb"; C1ExpressTable1.DbTableName = "Customers"; C1ExpressTable1.ExpressConnection.Fill(); DataGrid1.DataSource = C1ExpressTable1; |