0
I have a function in a VB.NET system that I use to execute queries in BD. The function is Public Shared type for simplicity. And there is doubt whether competing accesses to the function could generate problems.
This is user 'A' calls the function with a query and before the query is executed, user 'B' calls the same function with a different query. So this concurrent access can generate unexpected results?
Below the code:
Public Class ExecuteDB
Public Shared Function Execute(ByVal query As String) As DataSet
Dim ds As New DataSet
If query Is Nothing OrElse query = "" Then
Return ds
End If
Dim connectionString As String = ConfigurationManager.ConnectionStrings("CnString").ConnectionString
Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(query, connection)
Try
Dim da As New SqlDataAdapter(command)
da.Fill(ds)
Catch ex As Exception
Throw ex
End Try
End Using
Return ds
End Function
End Class