|
-
Jul 17th, 2008, 08:13 AM
#1
Thread Starter
New Member
Null/Nothing value to text/adLongVarChar??
I have a stored procedure and my VB6 apps need to pass the parameter to it.
I need to pass Null value to a text(in T-sql), if I use:
Code:
Set prm5 = cmd.CreateParameter("@xmlStation", adLongVarChar, adParamInput, 0, null)
or
Code:
Set prm5 = cmd.CreateParameter("@xmlStation", adLongVarChar, adParamInput, , null)
I get:
Code:
Parameter object is improperly defined. Inconsistent or incomplete information was provided.
Anyone knows?
-
Jul 17th, 2008, 08:22 AM
#2
Re: Null/Nothing value to text/adLongVarChar??
The size parameter is basically for the length of the field (technically the maximum length of the parameter), not the length of the value you are passing.
A size of 0 is not apt for a text/char based parameter, even if the value will only ever be Null.
-
Jul 17th, 2008, 06:46 PM
#3
Thread Starter
New Member
Re: Null/Nothing value to text/adLongVarChar??
 Originally Posted by si_the_geek
The size parameter is basically for the length of the field (technically the maximum length of the parameter), not the length of the value you are passing.
A size of 0 is not apt for a text/char based parameter, even if the value will only ever be Null.
Sorry, I do not get you. SO what's the value I should pass for the 4th parameter for size, and 5th parameter for value, since even this one also fail:
Code:
Set prm5 = cmd.CreateParameter("@xmlStation", adLongVarChar, adParamInput, , null)
-
Jul 18th, 2008, 06:11 AM
#4
Re: Null/Nothing value to text/adLongVarChar??
The size parameter should be the size of the field (or whatever it is) that this parameter refers to - so if the field is VarChar(400) it should be 400
The value parameter should Null (or perhaps vbNull).
-
Jul 19th, 2008, 08:58 AM
#5
Thread Starter
New Member
Re: Null/Nothing value to text/adLongVarChar??
but datatype "text" is equvalent to varchar(max) in SQL2005, means runtime allocated size, or size depends on memory. It make no sense to put a maximum values, furthermore null not work(let alone vbNull) as i mentioned on previous post
-
Jul 19th, 2008, 10:22 AM
#6
Re: Null/Nothing value to text/adLongVarChar??
 Originally Posted by si_the_geek
The value parameter should Null (or perhaps vbNull).
vbNull is the worst idea ever. (ETA: Not your idea; the VB6 developers including it in the language was a bad idea.) It is not a Null, and in fact it has nothing to do with Null anymore than vbString has to do with strings. Both vbNull and vbString are longs; they are constants used to compare against the return value of VarType().
Using vbNull for anything other than comparing against VarType() is like using vbString to initialize an empty string. No joy.
Just for completeness:
vbEmpty = 0 (Uninitialized)
vbNull = 1
vbInteger = 2
vbLong = 3
vbSingle = 4
vbDouble = 5
vbCurrency = 6
vbDate = 7
vbString = 8
vbObject = 9
vbError = 10
vbBoolean = 11
vbVariant = 12
They would have been fine if they'd left it at that, but then they went ahead and added the constant vbNullString. Endless confusion ensued. (If vbNullString is a null string, vbNull is a Null, right? Doh!)
Last edited by Ellis Dee; Jul 19th, 2008 at 10:29 AM.
-
Jul 19th, 2008, 10:55 PM
#7
Thread Starter
New Member
Re: Null/Nothing value to text/adLongVarChar??
hi Ellis Dee, thanks for your info. So, what's the answer for my question?
-
Jul 20th, 2008, 01:49 AM
#8
Re: Null/Nothing value to text/adLongVarChar??
si_the_geek gave you the answer. I was merely responding to his parenthetical aside.
-
Jul 20th, 2008, 09:01 AM
#9
Thread Starter
New Member
Re: Null/Nothing value to text/adLongVarChar??
really? this?
Code:
The size parameter should be the size of the field (or whatever it is) that this parameter refers to - so if the field is VarChar(400) it should be 400
but datatype "text" is equvalent to varchar(max) in SQL2005, means runtime allocated size, or size depends on memory. It make no sense to put a maximum values
-
Jul 20th, 2008, 09:09 AM
#10
Re: Null/Nothing value to text/adLongVarChar??
In that case, I wish I could help you, but I have no idea.
-
Jul 20th, 2008, 09:52 AM
#11
Re: Null/Nothing value to text/adLongVarChar??
Well you don't need to specify the exact length of the field, just the maximum you could pass via the parameter. Even if you are passing Null, set the size to something reasonable (eg: 50).
 Originally Posted by Ellis
vbNull is the worst idea ever. ...
I knew there was a reason it didn't seem right!
-
Jul 20th, 2008, 07:46 PM
#12
Thread Starter
New Member
Re: Null/Nothing value to text/adLongVarChar??
 Originally Posted by si_the_geek
Well you don't need to specify the exact length of the field, just the maximum you could pass via the parameter. Even if you are passing Null, set the size to something reasonable (eg: 50).
I knew there was a reason it didn't seem right!
Haha, I passed "0" is not working, but "1" it works. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|