Database Reference
In-Depth Information
•
For the Size property, set Width to 263 and Height to 282.
6.
Now your PopDataSet form in the Design view should look like Figure 15-3.
Figure 15-3.
The
Design view of the PopDataSet form
7.
Double-click the empty surface of the
PopDataSet.cs
form, and it will open the
code editor window, showing the
PopDataSet_Load
event. Modify the
PopDataSet_Load
event to look like Listing 15-1.
Listing 15-1.
PopDataSet.cs
Using System.Data.SqlClient;
private void PopDataSet_Load(object sender, EventArgs e)
{
// Connection string
string connString = @" server=.\sql2012;database=AdventureWorks;
Integrated Security=true";
// Query
string sql = @"select Name,ProductNumber
from Production.Product
where SafetyStockLevel > 600";
// Create connection
SqlConnection conn = new SqlConnection(connString);