Guest User

Untitled

a guest
Sep 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. using System;
  2. using System.Data.SqlClient;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Executing query...");
  9. string customerID = "ID_HERE";
  10. using (SqlConnection connection = new SqlConnection("CONNECTION_STRING"))
  11. {
  12. connection.Open();
  13.  
  14. using (SqlCommand command = new SqlCommand(
  15. "SELECT col0, col1, col2, col3, col4, col5, col6, col7, col8, col9 FROM Drop_GlobalCustomerVehicle WHERE GlobalCustomerID LIKE @ID", connection))
  16. {
  17.  
  18. command.Parameters.Add(new SqlParameter("ID", customerID));
  19.  
  20. SqlDataReader reader = command.ExecuteReader();
  21. while (reader.Read())
  22. {
  23. int col0 = reader.GetInt32(0);
  24. int col1 = reader.GetInt32(1);
  25. string col2 = reader.GetString(2);
  26. string col3 = reader.GetString(3);
  27. int col4 = reader.GetInt32(4);
  28. int col5 = reader.GetInt32(5);
  29. short col6 = reader.GetInt16(6);
  30. string col7 = reader.GetString(7);
  31. string col8 = reader.GetString(8);
  32. int col9 = reader.GetInt32(9);
  33. Console.WriteLine("col0 = {0}, col1 = {1}, col2 = {2}, col3 = {3}, col4 = {4}, col5 = {5}, col6 = {6}, col7 = {7}, col8 = {8}, col9 = {9}",
  34. col0,
  35. col1,
  36. col2,
  37. col3,
  38. col4,
  39. col5,
  40. col6,
  41. col7,
  42. col8,
  43. col9
  44. );
  45. }
  46. }
  47. }
  48. Console.WriteLine("Press any key to exit.");
  49. Console.ReadKey();
  50. }
  51.  
  52. }
Add Comment
Please, Sign In to add comment