Skip to content

Create and configure the SQL Data Source and bind it to the Grid Control.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-grid-create-configure-sql-data-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Data Grid - Configure the SQL Data Source and bind it to the grid

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";
  }

Files to Review

Documentation

See Also

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)