A Wrapper Class for DML Statements Using Visual Basic.NET - Completing the class
(Page 7 of 7 )
Before we complete the class, we need to examine two more methods. Let us consider the first one:
PublicSub Criteria(ByVal Condition As String)
Select Case m_CommandType
Case CommandType.Update
m_SQL = Left(m_SQL, Len(m_SQL) - 1)
m_SQL &= " WHERE " & Condition
End Select
End Sub
The above method is mainly used to add a condition to the DML command. The second is the following:
PublicSub Clear()
Select Case m_CommandType
Case CommandType.Insert
m_SQL = "INSERT INTO "
m_ColValList = ""
m_ColNameList = ""
m_FileColNames = Nothing
m_FileByteArrays = Nothing
Case CommandType.Update
m_SQL = "UPDATE "
m_FileColNames = Nothing
m_FileByteArrays = Nothing
End Select
End Sub
If you wanted to clear the existing DML command frame, you can use the above command. It is mainly used when you want to reuse the same DML object several times.
Working with the above class is as simple as the following code:
Dim ins As New DMLLib(DMLLib.CommandType.Insert, db)
With ins
.TableName = "emp"
.addColumn("empno", "1001")
.addColumn("ename", "jag")
.ExecuteCommand()
End With
If necessary, you can even put "addColumn" in a loop to work with a larger number of columns. The only important issue is that the "TableName" must be the first assignment to the DMLLib object.
Any feedback, suggestions, bugs, errors, improvements etc., are highly appreciated at jag_chat@yahoo.com.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |