aspvbnetnerd
Programmer
I have a problem using interface. The problem is that I have to open the database connection 2 times
I have asked a simular question before.
If I create one class DataAdapter that implements IDataInsert and IDataUpdate
The IDataInsert handles the insert to the database and IDataUpdate handles the update to the database.
Orginise you say
Class IDataInsert
Class IDataUpdate
Class DataUpdapter that Implements IDataUpdate and IDataInsert
And the Init sub is this code
If I the want to insert and after that update the database I would have do It like this.
I dont want open the database connection twice
I hope you understand my problem and could help and solve this. :-(
George
I have asked a simular question before.
If I create one class DataAdapter that implements IDataInsert and IDataUpdate
The IDataInsert handles the insert to the database and IDataUpdate handles the update to the database.
Orginise you say
Class IDataInsert
Code:
Public Interface IDataInsert
Sub init(ByRef connString As String)
End Interface
Class IDataUpdate
Code:
Public Interface IDataUpdate
Sub init(ByRef connString As String)
End Interface
Class DataUpdapter that Implements IDataUpdate and IDataInsert
And the Init sub is this code
Code:
Public Class DataUpdater
Implements IDataUpdater
Private Sub init(ByRef connString As String) Implements IDataUpdater.init
mDbConn = New SqlConnection(connString)
mDbConn.Open()
End Sub
End Class
If I the want to insert and after that update the database I would have do It like this.
Code:
Private mDataUpdate As IDataUpdater 'Handles database update
Private mDataInsert As IDataInsert 'Handles database insert
mDataInsert = New DataAdapter
mDataInsert.init(prvConnString)
mDataUpdate = New DataAdapter
mDataUpdate.init(prvConnString)
I dont want open the database connection twice
I hope you understand my problem and could help and solve this. :-(
George