O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.7. The Data Provider

All interactions with a database are carried out through a data provider. In Section 5.10 we walked through the OLE DB data provider. This section steps through the analogous use of the SQL Server data provider defined within the System.Data.SqlClient namespace. It can be used with Microsoft SQL Server 7.0 or later versions.

Here are the steps necessary, using the SQL Server data provider, first to connect to and select data from a database, and then to fill a DataSet object with the retrieved data:

1.
Create a connection string. The string must identify the server, user ID, password, and database—for example,
string cs = "server=localhost;uid=sa;pwd=;database=northwind";
2.
Create a selection command string. This minimally ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required