Hello!
This is also a working console program.
It seems to me that a DataSet is actually the result of the query as in my
example
because the result is from two tables.
Is this correct understood ?
What will happen if you change some row and then call the update for
DataAdapter object ?
static void Main(string[] args)
{
//Specify SQL Server-specific connection string
SqlConnection thisConnection = new SqlConnection(
@"Server=UHT-DEMO1; Integrated Security=True;" +
"Database=north wind");
//Create DataAdapter object
SqlDataAdapter thisAdapter = new SqlDataAdapter(
"Select Customers.Custo merID, OrderID, ContactName from
Customers, Orders " +
"where Customers.Custo merID = Orders.Customer ID and " +
"OrderID = 10248", thisConnection) ;
//Create DataSet to contain related data tables, rows and
columns
DataSet thisDataSet = new DataSet();
//Fill DataSet using query defined previously for DataAdapter
thisAdapter.Fil l(thisDataSet, "Test");
foreach (DataRow theRow in thisDataSet.Tab les["Test"].Rows)
Console.WriteLi ne("Row = {0}", theRow["CustomerID "] + "\t" +
theRow["ContactNam e"]);
thisConnection. Close();
Console.WriteLi ne("Program finished, press Enter/Return to
continue");
Console.Read();
}
This is also a working console program.
It seems to me that a DataSet is actually the result of the query as in my
example
because the result is from two tables.
Is this correct understood ?
What will happen if you change some row and then call the update for
DataAdapter object ?
static void Main(string[] args)
{
//Specify SQL Server-specific connection string
SqlConnection thisConnection = new SqlConnection(
@"Server=UHT-DEMO1; Integrated Security=True;" +
"Database=north wind");
//Create DataAdapter object
SqlDataAdapter thisAdapter = new SqlDataAdapter(
"Select Customers.Custo merID, OrderID, ContactName from
Customers, Orders " +
"where Customers.Custo merID = Orders.Customer ID and " +
"OrderID = 10248", thisConnection) ;
//Create DataSet to contain related data tables, rows and
columns
DataSet thisDataSet = new DataSet();
//Fill DataSet using query defined previously for DataAdapter
thisAdapter.Fil l(thisDataSet, "Test");
foreach (DataRow theRow in thisDataSet.Tab les["Test"].Rows)
Console.WriteLi ne("Row = {0}", theRow["CustomerID "] + "\t" +
theRow["ContactNam e"]);
thisConnection. Close();
Console.WriteLi ne("Program finished, press Enter/Return to
continue");
Console.Read();
}
Comment