function to build sql update string based upon data type

  • Thread starter Thread starter TJS
  • Start date Start date
T

TJS

looking for generic function to build sql update string for values coming
from a form.
I've seen these for classic asp but I'm not finding equivalent in asp.net

Googleing did not help so far
 
I want to do something like this but don't know how .net gets the datatype
or which type of database connection to use for updating field


======================

strName = vFldname
intType = Cint(objRS(vFldname).Type)
strNewValue = vFldValue

If strName <> "ID" Then 'skip primary key
Select Case intType
Case 2, 3, 4, 5, 6, 17 'number fields
If not IsNumeric(strNewValue) Then strNewValue = Null
Case 11 'yes/no fields
If UCase(strNewValue) = "ON" Then
strNewValue = 1
Else
strNewValue = 0
End If
Case 7,135 'date/time fields
If not IsDate(strNewValue) Then strNewValue = Null
Case Else 'string fields
If Trim(strNewValue) & "" = "" Then strNewValue = Null
End Select

strNewValue = dataPrep(strNewValue)
objRS(strName) = strNewValue

End If
 
Back
Top