I have an application that can use two different Databases, so I wrote a wrapper class for each Database.
Here is a snippet of the code from the wrapper library:
Public Function ExecuteQuery(SQL As String) As DataTable
Return GetDataTable(SQL, Nothing)
Private Function GetDataTable(ByVal query As String, ByVal ParamArray args() As MySqlParameter) As DataTable
Dim dt As New DataTable
Dim cmd As New MySqlCommand(query, GetConnection())
If args IsNot Nothing Then
For Each p As MySqlParameter In args
Dim da As New MySqlDataAdapter(cmd)
I can call this code from my main program and it works just fine. The problem I have to writing back to the database. For simple single commands I can handle this easily, but I have one situation where the user will be making multiple Insert/Edit/Delete operations on a large DataTable. How can I simply dump these changes back into the database in one step?
I've never used DataAdapters and CommandBuilders but they look like what I need. But how can I expose those from the library without the main application requiring a reference to the specific database dll? (I cannot put a reference to the actual DB dll in my main code because of a version conflict. Using a wrapper class was my solution to this problem).