S
shapper
Hello,
I have created a function which creates a DataTable from a Database.
However, I want to be able to use an Access or aSQL database.
Do I need to create 2 complete different functions?
The method is the same, only the types change.
Here is my code:
' Define connection
Dim connection As New
SqlClient.SqlConnection(connectionString.ToString)
' Define command
Dim command As New SqlClient.SqlCommand
With command
.CommandText = "GetRecords"
.Connection = connection
.CommandType = CommandType.StoredProcedure
End With
' Add command parameters
With command.Parameters
.Add(New SqlClient.SqlParameter("@Value", Value))
End With
connection.Open()
...
Create DataTable
...
connection.Close()
Thanks,
Miguel
I have created a function which creates a DataTable from a Database.
However, I want to be able to use an Access or aSQL database.
Do I need to create 2 complete different functions?
The method is the same, only the types change.
Here is my code:
' Define connection
Dim connection As New
SqlClient.SqlConnection(connectionString.ToString)
' Define command
Dim command As New SqlClient.SqlCommand
With command
.CommandText = "GetRecords"
.Connection = connection
.CommandType = CommandType.StoredProcedure
End With
' Add command parameters
With command.Parameters
.Add(New SqlClient.SqlParameter("@Value", Value))
End With
connection.Open()
...
Create DataTable
...
connection.Close()
Thanks,
Miguel