- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- namespace Boek_Hoofdstuk_28
- {
- class Program
- {
- static void Main(string[] args)
- {
- SqlConnection thisConnection = new SqlConnection
- (
- @"Data Source=.SQLEXPRESS;" +
- @"AttachDbFilename=’C:Documents and SettingsJeroenYBureaubladNortwind database Voor SQLbiblio_2000.mdb’;" +
- @"Integrated Security=True;Connect Timeout=30;User Instance=true"
- );
- // Open connection
- thisConnection.Open();
- // Create command for this connection
- SqlCommand thisCommand = thisConnection.CreateCommand();
- // Specify SQL query for this command
- thisCommand.CommandText =
- "SELECT CustomerID, CompanyName from Customers";
- // Execute DataReader for specified command
- SqlDataReader thisReader = thisCommand.ExecuteReader();
- // While there are rows to read
- while (thisReader.Read())
- {
- // Output ID and name columns
- Console.WriteLine("t{0}t{1}",
- thisReader["CustomerID"], thisReader["CompanyName"]);
- }
- // Close reader
- thisReader.Close();
- // Close connection
- thisConnection.Close();
- Console.Write("Program finished, press Enter/Return to continue:");
- Console.ReadLine();
- }
- }
- }
Undefined
By: Guest | Date: Nov 17 2009 14:47 | Format: None | Expires: never | Size: 1.51 KB | Hits: 897
Latest pastes
57 minutes ago
10 hours ago
1 days ago
2 days ago
2 days ago