A Wrapper Class for DML Statements Using Visual Basic.NET - Executing the DML command
(Page 6 of 7 )
Once the DML command is framed, we need to execute it with a separate method. The method looks something like the following:
PublicSub ExecuteCommand()
If m_FileColNames Is Nothing Then 'if no images exist in the command
m_dbObject.SQLExecute(Me.GeneratedSQLCommand)
Else 'insert images as well
m_dbObject.SQLExecute(Me.GeneratedSQLCommand, m_FileColNames, m_FileByteArrays)
End If
End Sub
The above method works with another method called "GeneratedSQLCommand," which is defined as follows:
PublicReadOnly Property GeneratedSQLCommand()
Get
Select Case m_CommandType
Case CommandType.Insert
m_SQL = Replace(m_SQL, "()", "(" & m_ColNameList & ")", , 1)
m_SQL = Replace(m_SQL, "()", "(" & m_ColValList & ")")
Case CommandType.Update
If InStr(m_SQL, " WHERE ") = 0 Then
Return Left(m_SQL, Len(m_SQL) - 1)
End If
End Select
Return m_SQL
End Get
End Property
The method "ExecuteCommand" executes the DML command with the help of my data helper class provided in my previous articles. You can embed your own logic to execute the DML command at that point.
Next: Completing the class >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee