Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


vbscript recordset empty

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,24834
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> vbscript recordset empty
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 vbscript recordset empty - 8/12/2005 7:38:40 AM   
  kay

 

Posts: 2
Score: 0
Joined: 8/12/2005
Status: offline
Hello
I am trying to return a recordset using VB Script. One of the fields I am getting back is type Decimal. By some reason VB Script does not automatically size variable to this type. So I am have to exlicetly define is as Double. The proble is, if this field returns as empty, I get a type mismatch error when I try to assign an emty field value to a Double.
Is there a way arrond this problem?
 
 
Post #: 1
 
 RE: vbscript recordset empty - 8/12/2005 8:36:52 AM   
  ehvbs

 

Posts: 2058
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
vValue = objRS.Fields( <NameOrNumber> ).Value
If IsNull( vValue ) Then vValue = 0.0 Else vValue = CDbl( vValue )

[just written, not tested]

you loose the difference between 0.0 and NULL

(in reply to kay)
 
 
Post #: 2
 
 RE: vbscript recordset empty - 8/12/2005 8:44:38 AM   
  kay

 

Posts: 2
Score: 0
Joined: 8/12/2005
Status: offline
The whole problem is that I can't do:
vValue = objRS.Fields( <NameOrNumber> ).Value

vValue is not matching type with NULL if it is defined as Double. And if I don't define it as Double, I get upsupported type when I get the value back.
The value coming back from the db is type decimal

(in reply to kay)
 
 
Post #: 3
 
 RE: vbscript recordset empty - 8/12/2005 9:21:43 AM   
  ehvbs

 

Posts: 2058
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi kay,

probably I misunderstood you. I saw "VB Script", thought "VBScript" and wondered why you posted your
question in this forum. Do you write VBA code in Excel or Access?

If so, try this

Dim vValue as Variant
Dim dblValue as Double

vValue = objRS.Fields( <NameOrNumber> ).Value
If IsNull( vValue ) Then dblValue = 0.0 Else dblvValue = CDbl( vValue )

[still not tested]

(in reply to kay)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> vbscript recordset empty Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts