A Wrapper Class for DML Statements Using Visual Basic.NET - Adding a column to the INSERT or UPDATE command
(Page 3 of 7 )
The following is the code necessary for adding a new column to the respective DML command:
PublicSub addColumn(ByVal ColName As String, ByVal ColValue As
String, Optional ByVal ColType As DataType =
DataType.CharacterType)
'change the value according to datatype
Select Case m_CommandType
Case CommandType.Insert 'INSERT command
Select Case ColType
Case DataType.CharacterType
ColValue = "'" & ColValue & "'"
Case DataType.DateType
Dim s As String = Format(CDate(ColValue),
"yyyy/MM/dd")
Select Case m_dbObject.ConnectionType
Case DBConnType.MSSQL
ColValue = "'" & s & "'"
'Case "JET"
'ColValue = "#" & s & "#"
Case Else
ColValue = "'" & s & "'"
End Select
Case DataType.NumericType
ColValue = ColValue
End Select
If m_ColNameList = "" Then
m_ColNameList = ColName
Else
m_ColNameList &= ", " & ColName
End If
If m_ColValList = "" Then
m_ColValList = ColValue
Else
m_ColValList &= ", " & ColValue
End If
Case CommandType.Update 'UPDATE command
Select Case ColType
Case DataType.CharacterType
m_SQL &= ColName & "='" & ColValue & "',"
Case DataType.DateType
Dim s As String = Format(CDate(ColValue),
"yyyy/MM/dd")
Select Case m_dbObject.ConnectionType
Case DBConnType.MSSQL
m_SQL &= ColName & "='" & s &
"',"
'Case "JET"
' m_SQL &= ColName & "=#" & s
& "#,"
End Select
Case DataType.NumericType
m_SQL &= ColName & "=" & ColValue & ","
End Select
End Select
End Sub
Next: Adding code to add binary data for INSERT command >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee