Data Access (How Do I in C# Express)
This topic links to Help about widely used data access tasks. To view other categories of popular tasks explained in Help, see How Do I in C# Express.
Note
If you are using Visual C# Express Edition, some of the Help links on this page may be unavailable, depending on the options that you chose during installation. For more information, see Troubleshooting Visual C# Express.
General
How to: Install Sample Databases
Provides steps to install a sample database such as the Northwind sample database, SQL Server Express, SQL Server Compact 3.5, or an Access version of Northwind. (With Visual C# Express Edition your database must be installed on the local computer.)Walkthrough: Creating a Simple Data Application
Provides a step-by-step procedure to create a data application.
Connecting to Data in Visual Studio
Connecting to Data in Visual Studio Overview
Provides information about how to connect your application to data from many different sources, such as databases, Web services, and objects.Walkthrough: Connecting to Data in a Database
Provides a procedure to connect your application to data in Visual Studio by using the Data Source Configuration Wizard.Walkthrough: Connecting to Data in a Web Service
Provides a procedure to connect your application to data in a Web service by using the Data Source Configuration Wizard.Walkthrough: Connecting to Data in an Access Database
Provides a procedure to connect your application to data in an Access database by using the Data Source Configuration Wizard.
Creating and Designing Typed Datasets
How to: Create a Typed Dataset
Explains how to create a typed dataset by using the Data Source Configuration Wizard or the Dataset Designer.Walkthrough: Creating a Dataset with the Dataset Designer
Provides a procedure to create a dataset by using the Dataset Designer.Walkthrough: Creating a DataTable in the Dataset Designer
Provides a procedure to create a data table by using the Dataset Designer.Walkthrough: Creating a Relationship between Data Tables
Explains how to create two data tables without TableAdapters by using the Dataset.
TableAdapters
TableAdapter Overview
Provides an overview of TableAdapters which provides communication between your application and a database.Walkthrough: Creating a TableAdapter with Multiple Queries
Provides a procedure to create a TableAdapter in a dataset by using the Data Source Configuration Wizard. The walkthrough will show you how to create a second query in the TableAdapter by using the TableAdapter Query Configuration Wizard in the Dataset Designer.
Filling Datasets and Executing Queries
Filling Datasets and Querying Data Overview
Explains how to execute SQL statements or stored procedures against a data source by using TableAdapters or command objects.Walkthrough: Filling a Dataset with Data
Demonstrates how to create a dataset with one data table and fill it with data from the Customers table in the Northwind sample database.Walkthrough: Reading XML Data into a Dataset
Demonstrates how to create a Windows application that will load XML data into a dataset.
Displaying Data on Windows Forms
Displaying Data Overview
Provides a summary of the tasks, objects, and dialog boxes involved in creating data-bound Windows applications.Walkthrough: Displaying Data on a Form in a Windows Application
Provides a procedure to create a simple form that displays data from a single table in several individual controls.Walkthrough: Displaying Related Data on a Form in a Windows Application
Provides a procedure to work with data that comes from more than one table, and often, data from related tables.Walkthrough: Creating a Form to Search Data in a Windows Application
Shows how to create a query that returns customers in a specific city, and modify the user interface so that users can enter a city's name and press a button to execute the query.Walkthrough: Creating a Lookup Table
Provides a procedure to display information from one table, depending on the value of a foreign-key field in another table.
Databinding
Walkthrough: Creating a User Control that Supports Simple Data Binding
Shows how to create a control that implements the DefaultBindingPropertyAttribute. This control is like a text box or check box and can contain one property that can be bound to data.Walkthrough: Creating a User Control that Supports Complex Data Binding
Shows how to create a control that implements the ComplexBindingPropertiesAttribute. This control contains DataSource and DataMember properties that can be bound to data; similar to a DataGridView, or ListBox.Walkthrough: Creating a User Control that Supports Lookup Databinding
Shows how to create a control that implements LookupBindingPropertiesAttribute. This control contains three properties that can be bound to data; similar to a ComboBox.Object Binding in Visual Studio
Explains design-time tools for working with custom objects instead of datasets and Web services, as the data source in your application.
Editing Data in Datasets
- Editing Data in Datasets Overview
Provides a table that contains links to the common tasks associated with editing and querying data in a dataset.
Validating Data
Data Validation Overview
Provides an overview of validating data, which confirms that the values being entered into data objects comply with the constraints in a dataset's schema, and also to the rules established for your application.Walkthrough: Adding Validation to a Dataset
Explains how to use the ColumnChanging event to verify that an acceptable value is being entered into the record.
Saving Data
Saving Data Overview
Explains how writing information to the original data source is separate from modifying the data in the dataset.Concurrency Control in ADO.NET
Explains common methods of concurrency control and specific ADO.NET features for handling concurrency errors.Walkthrough: Saving Data with the TableAdapter DBDirect Methods
Provides detailed instructions to execute SQL statements directly against a database by using the DbDirect methods of a TableAdapter.Walkthrough: Handling a Concurrency Exception
Contains a procedure to create a Windows application that illustrates catching a DBConcurrencyException, locating the row that caused the error, and one strategy for handling it.
Data Resources
Data User Interface Elements
Contains information about all the dialog boxes and wizards that you use when you design data access in your applications.ADO.NET Data Adapters
Provides information about ADO.NET data-adapter objects and how to work with them in Visual Studio.
Language-Integrated Query (LINQ)
Getting Started with LINQ in C#
Provides background information about LINQ queries.Walkthrough: Writing Queries in C# (LINQ)
Provides examples of the basic LINQ query clauses.LINQ Query Expressions (C# Programming Guide)
Provides information about query expressions in C#, with examples and pointers to additional documentation.
Using LINQ to Objects
How to: Query for Sentences that Contain a Specified Set of Words (LINQ)
Shows how to split text files on arbitrary boundaries and performing queries against each part.How to: Find the Set Difference Between Two Lists (LINQ)
Shows how to use the Except method to retrieve the items that are in one file but not the other.How to: Query for Characters in a String (LINQ)
Shows how to treat a string as an IEnumerable object.
Using LINQ to SQL
Walkthrough: Simple Object Model and Query (C#) (LINQ to SQL)
Shows how to create an entity class and execute a simple query.Walkthrough: Manipulating Data (C#) (LINQ to SQL)
Shows how to add, update, delete and modify data in a database.Walkthrough: Querying Across Relationships (C#) (LINQ to SQL)
Shows how to query across tables that have been mapped into a hierarchical object relationship.Walkthrough: Simple Object Model and Query (C#) (LINQ to SQL)
Introduces the object-relational mapping concepts in LINQ to SQL.Walkthrough: Using Only Stored Procedures (C#) (LINQ to SQL)
Shows how to use stored procedures in LINQ to SQL.How to: Represent Primary Keys (LINQ to SQL)
Shows how to represent primary keys in LINQ to SQL.How to: Display Generated SQL (LINQ to SQL)
Shows how to display and view the SQL that is generated and issued to the database by the LINQ to SQL runtime.How to: Handle Composite Keys in Queries (LINQ to SQL)
Shows how to sort and group by composite key values.How to: Directly Execute SQL Queries (LINQ to SQL)
Shows how to issue SQL commands instead of a LINQ query.
Using LINQ to XML
How to: Control Namespace Prefixes (C#) (LINQ to XML)
Shows how to control namespace prefixes in LINQ to XML.How to: Retrieve a Collection of Elements (LINQ to XML)
Shows how to retrieve a collection of elements in LINQ to XML.How to: Retrieve the Value of an Element (LINQ to XML)
Shows how to retrieve the value of an element in LINQ to XML.How to: Filter on Element Names (LINQ to XML)
Shows how to filter on elements in LINQ to XML.How to: Chain Axis Method Calls (LINQ to XML)
Shows how to retrieve elements at a specified depth.How to: Retrieve a Single Child Element (LINQ to XML)
Shows how to retrieve a single child element.How to: Retrieve a Collection of Attributes (LINQ to XML)
Shows how to retrieve a collection of attributes.How to: Retrieve a Single Attribute (LINQ to XML)
Shows how to retrieve a single attribute.How to: Retrieve the Value of an Attribute (LINQ to XML)
Shows how to retrieve the value of an attribute.How to: Project a New Type (LINQ to XML)
Shows how to use a query to output a type that differs from the input type.How to: Join Two Collections (C#) (LINQ to XML)
Shows how to join two XML files or streams into one.
Using LINQ to DataSet
Loading Data Into a DataSet
Describes how to load data into a dataset.Single-Table Queries (LINQ to DataSet)
Describes how to perform queries against a single table in a dataset.Cross-Table Queries (LINQ to DataSet)
Describes how to perform queries across multiple tables in a dataset.Querying Typed DataSets
Describes how to perform queries against typed datasets.LINQ to DataSet Examples
Provides many examples of how to perform various query operations such as restriction, projection, ordering, partitioning, and so on.
Work with Microsoft SQL Server Compact 3.5
How to: Add a SQL Server Compact 3.5 Database to a Project
Describes how to add a new or existing SQL Server Compact 3.5 database to a Windows-based application.How to: Deploy a SQL Server Compact 3.5 Database with an Application
Describes how to configure deployment for a Windows-based application that includes a SQL Server Compact 3.5 database.Walkthrough: Adding a SQL Server Compact 3.5 Database to an Application and Deploying it
Provides step-by-step details for incorporating a SQL Server Compact 3.5 database in a Windows-based application and configuring the application for deployment.
Creating SQL Server Objects in Managed Code
SQL Server Projects
Explains how to use .NET Framework languages and the Transact-SQL programming language to create database objects such as stored procedures and triggers, and to retrieve and update data for Microsoft SQL Server databases.Walkthrough: Creating a Stored Procedure in Managed Code
Provides step-by-step instructions for the following:Creating a stored procedure in managed code.
Deploying the stored procedure to a SQL Server database.
Creating a script to test the stored procedure on the database.
Query data in the database to confirm that the stored procedure executed correctly.
Object Relational Designer (O/R Designer)
O/R Designer Overview
Explains what the O/R Designer is and provides information about the tasks you can accomplish with it.How to: Add LINQ to SQL Classes to a Project (O/R Designer)
Describes how to add an empty LINQ to SQL file to a project.How to: Create LINQ to SQL Classes Mapped to Tables and Views (O/R Designer)
Describes how to create entity classes that are mapped to tables and views in a database.How to: Create DataContext Methods Mapped to Stored Procedures and Functions (O/R Designer)
Describes how to create DataContext methods that run stored procedures or functions when they are called.How to: Assign Stored Procedures to Perform Updates, Inserts, and Deletes (O/R Designer)
Describes how to configure a DataContext method to use stored procedures when saving data from entity classes back to a database.How to: Turn Pluralization On and Off (O/R Designer)
Describes how to turn on and off the automatic renaming of classes that are added to the O/R Designer.How to: Configure Inheritance by Using the O/R Designer
Describes how to configure entity classes by using single-table inheritance with the O/R Designer.Walkthrough: Creating LINQ to SQL Classes (O/R Designer)
Provides step-by-step instructions for designing entity classes by using the O/R Designer and for displaying data on a Windows Form.Walkthrough: Creating LINQ to SQL Classes by Using Single-Table Inheritance (O/R Designer)
Provides step-by-step instructions for configuring entity classes by using single-table inheritance with the O/R Designer.
Other Resources
These Web sites are excellent resources for finding more information, seeing what other Express users are doing, and stay in touch as Visual C# Express grows.
Visual C# Developer Center
Serves as a central location for information about Visual C# Express Edition. Includes videos, new tools, and other downloads.Beginner Developer Learning Center
Serves as a central location for learning materials for the beginner developer. Includes video tutorials, articles, the How-To Reference Library, and Kid's Corner.Coding4Fun
Includes lots of articles and coding tips for the Visual C# Express developer.