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
 
what part is the issue? You should be able to do it the same way really.....
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top