rs(x).type question

Results 1 to 2 of 2

Thread: rs(x).type question

  1. #1
    the other steve Guest

    Default rs(x).type question

    I have a script i got from the web (maybe even this site) that checks the datatype of a field to determine the presentation format. however, the values in the script don&#039;t match the values that I got from the following test: (this is all MS Access, not MS SQL, btw)<BR><BR>&#039;testtable has nine fields, eached named the same as the chosen datatype<BR>query="select * from testtable"<BR> query, conn<BR>For x=0 to 8<BR>response.write rs(x).name & ": " & rs(x).type<BR>next<BR><BR>RESULT<BR><BR>autonumber : 3<BR>text: 202<BR>memo: 203<BR>number: 3<BR>datetime: 135<BR>currency: 6<BR>yesno: 11<BR>ole object: 205<BR>hyperlink: 203<BR><BR>The script uses:<BR><BR> Select Case intType<BR> Case 2<BR> strFieldType = "Integer"<BR> Case 3<BR> strFieldType = "Long Integer"<BR> Case 4<BR> strFieldType = "Single"<BR> Case 5<BR> strFieldType = "Double"<BR> Case 6<BR> strFieldType = "Currency"<BR> Case 7<BR> strFieldType = "Date/Time"<BR> Case 11<BR> strFieldType = "Boolean"<BR> Case 17<BR> strFieldType = "Byte"<BR> Case 7<BR> strFieldType = "Date/Time"<BR> Case Else<BR> strFieldType = "String"<BR> End Select<BR><BR>My question: Is this a difference between Access and SQL? Or is the script just bad? Or what?

  2. #2
    Join Date
    Dec 1969

    Default Nothing directly to do with DB in use...

    ...these are the *ADO* datatypes.<BR><BR>Here&#039;s the root reference for the type number you see there:<BR><BR><BR><BR>That script is pretty incomplete, in my opinion, but it&#039;s not wrong as far as it goes.<BR><BR> that I look again, those 203 numbers do seem pretty funky. The docs say they should occur only in a Parameter object, not in a Field object as they are here. Huh. Wonder why.<BR><BR>Personally, I think you are better off checking the VBSCRIPT DATA TYPE of the value. You don&#039;t really care how the data is stored in the DB; you *do* care what VBS thinks it is.<BR><BR>So instead of<BR>&nbsp; &nbsp; rs(x).type<BR>you might want to use<BR>&nbsp; &nbsp; TypeName( rs(x).Value )<BR>or <BR>&nbsp; &nbsp; VarType( rs(x).Value )<BR><BR>and now look at the VBS docs for VarType and TypeName to see what you can use/expect.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts