This example demonstrates how to:
-
Create and configure the SqlDataSource component
private static SqlDataSource InitData() { MsSqlConnectionParameters connectionParameters = new MsSqlConnectionParameters("localhost", "nwind.mdf", "username", "password", MsSqlAuthorizationType.SqlServer); SqlDataSource ds = new SqlDataSource(connectionParameters); CustomSqlQuery query = new CustomSqlQuery(); query.Name = "customQuery1"; query.Sql = "SELECT * FROM Products"; ds.Queries.Add(query); ds.Fill(); return ds; }
-
Bind the
GridControl
to a Microsoft SQL Server database.
private void Init() {
SqlDataSource ds = InitData();
Grid.DataSource = ds;
Grid.DataMember = "customQuery1";
}
- How to use the SqlDataSource component to provide data for the GridControl at design time
- Data Binding - DevExpress WinForms Troubleshooting
(you will be redirected to DevExpress.com to submit your response)