using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; namespace ReportOrders { class Report { static void Main(string[] args) { SqlConnection dataConn = new SqlConnection(); try { dataConn.ConnectionString = "Integrated Security=true;Initial Catalog=AdventureWorks;" + "Data Source=."; dataConn.Open(); Console.Write("Please enter a Manager ID "); string EmployeeID = Console.ReadLine(); SqlCommand dataComm = new SqlCommand(); dataComm.Connection = dataConn; dataComm.CommandText = "SELECT EmployeeID, ContactID,Title, BirthDate " + "FROM HumanResources.Employee WHERE ManagerID='" + EmployeeID + "'"; Console.WriteLine("About to execute: {0}\n\n", dataComm.CommandText); SqlDataReader dataReader = dataComm.ExecuteReader(); while (dataReader.Read()) { int ContactID = dataReader.GetInt32(0); string Title = dataReader.GetString(2); int BirthDate = dataReader.GetInt32(1); Console.WriteLine( "EmployeeID: {0}\nID: {1}\n{2}\n{3}\n", EmployeeID, ContactID, Title, BirthDate); } dataReader.Close(); } catch (SqlException e) { Console.WriteLine("Error accessing the database: {0}", e.Message); } finally { dataConn.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)