function to build sql update string based upon data type

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
 
T

TJS

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top