Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Public Function getCustomer()
  2.  
  3. Dim sConnectionString As String = ConfigurationManager.AppSettings("dbTrainingDSN")
  4.  
  5. Dim cnSqlConnection1 As New SqlConnection(sConnectionString)
  6. 'Create a command for SQL. In this case we're calling the getCustomer stored Procedure.
  7. Dim cmdGetCustomer As New SqlCommand
  8. cmdGetCustomer.CommandText = "Pr_GetCustomer"
  9. cmdGetCustomer.CommandType = CommandType.StoredProcedure
  10. cmdGetCustomer.Connection = cnSqlConnection1
  11.  
  12. 'Open connection
  13. cnSqlConnection1.Open()
  14.  
  15. 'Select command and fill data using DA
  16. Dim daCustomer As System.Data.SqlClient.SqlDataAdapter
  17. Dim dtCustomer As New DataTable
  18.  
  19. Try
  20. daCustomer = New System.Data.SqlClient.SqlDataAdapter
  21. daCustomer.SelectCommand = cmdGetCustomer
  22. daCustomer.Fill(dtCustomer)
  23. Catch Err As System.Exception
  24. End Try
  25.  
  26. 'Close connection and get the tables
  27. cnSqlConnection1.Close()
  28. Return dtCustomer
  29.  
  30. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement