如何通过提供动态案例查询,将动态查询传递给后续函数,因为我希望每次主程序中的数据。
公共类DBConnection
Function MyDBConnection(ByRef sqlquery As String)
Dim sCommand As SqlCommand
Dim sAdapter As SqlDataAdapter
Dim sBuilder As SqlCommandBuilder
Dim sDs As DataSet
Dim connectionString As String = "Data Source=ATIFTARIQ;Initial Catalog=ABC_University;Integrated Security=True"
Dim connection As New SqlConnection(connectionString)
connection.Open()
sCommand = New SqlCommand(sqlquery, connection)
sAdapter = New SqlDataAdapter(sCommand)
sBuilder = New SqlCommandBuilder(sAdapter)
sDs = New DataSet()
sAdapter.Fill(sDs, "Files")
connection.Close()
Return sDs
End Function