Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 11022
  • Last Modified:

adVarChar or adLongVarChar???

I am using the following code to access a stored procedure in my database (from my VB application to my SQL Server database):

Public Function insert_News(ByVal title As Variant, _
                            ByVal author As Variant, _
                            ByVal summary As Variant, _
                            ByVal text As Variant) As ADODB.Recordset
    On Error GoTo ErrorHandler

    Set insert_News = RunSPWithRS_Null("insert_News", _
            Array("@title", adVarChar, 255, title), _
            Array("@author", adVarChar, 200, author), _
            Array("@summary", adLongVarChar, 600, summary), _
            Array("@text", adLongVarChar, 5000, text))
    CtxSetComplete
    Exit Function
   
ErrorHandler:
    On Error Resume Next
    Set insert_News = Nothing
   
End Function

This calls the stored procedure insert_News and passes the 4 parameters. My question is:

For the fields summary and text, should I use adVarChar or adLongVarChar? What is the limit of adVarChar and that of adLongVarChar?

What is the difference between adVarChar and adVarWChar?

Additionally, in another field which I hold currency values in Euros, and the datatype is Numeric (16,2) in the SQL Server. What should I declare the value inside my VB application when I call this stored procedure? Should I use

Array("@amount", adNumeric, 9, amount)

?

Thanks for the time
George
0
poutses
Asked:
poutses
  • 3
  • 3
1 Solution
 
poutsesAuthor Commented:
Just to let you know, I am using nvarchar and ntext in my database. Should I be using adVarWChar and adLongVarWChar instead of what I am using now?

Thanks again
0
 
Anthony PerkinsCommented:
If this link:
http://www.able-consulting.com/ADODataTypeEnum.htm

Does not answer all your questions, ask.
0
 
poutsesAuthor Commented:
this partially solves my problem. It did not answer my question regarding the AdNumeric, which is the one below:

"Additionally, in another field which I hold currency values in Euros, and the datatype is Numeric (16,2) in the SQL Server. What should I declare the value inside my VB application when I call this stored procedure? Should I use

Array("@amount", adNumeric, 9, amount)"

What is the integer to add next to adNumeric? Is 9 enough, or should I make it 12, or 18?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Anthony PerkinsCommented:
9 is the size in bytes and that covers anything up to a numeric of precision of 18.  However, in order to pass that parameter to a stored procedure you will also have to set the precision (18) and the scale (2).  Typically this is done as follows:
cmd.Parameters("@NumericParameter").Precision = 18
cmd.Parameters("@NumericParameter").NumericScale = 2
0
 
poutsesAuthor Commented:
I am sorry to insist, but how do I implement this in the following stored procedure?

Public Function ADMIN_add_creditdebit(ByVal user_id As Variant, _
                                    ByVal cd_name As Variant, _
                                    ByVal cd_poso As Variant, _
                                    ByVal cd_code As Variant) As ADODB.Recordset
    On Error GoTo ErrorHandler

    Set ADMIN_add_creditdebit = RunSPWithRS_Null("ADMIN_add_creditdebit", _
            Array("@user_id", adInteger, 4, user_id), _
            Array("@cd_name", adVarWChar, 255, cd_name), _
            Array("@cd_poso", adNumeric, 9, cd_poso), _
            Array("@cd_code", adVarWChar, 255, cd_code))
   
    CtxSetComplete
    Exit Function
   
ErrorHandler:
    On Error Resume Next
    Set ADMIN_add_creditdebit = Nothing
   
End Function

Thanks!
0
 
Anthony PerkinsCommented:
I am sorry, it looks like I overlooked this comment.  Is this now fully resolved?
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now