?
Solved

adVarChar or adLongVarChar???

Posted on 2005-03-30
6
Medium Priority
?
10,760 Views
Last Modified: 2013-12-25
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
Comment
Question by:poutses
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:poutses
ID: 13660210
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13667433
If this link:
http://www.able-consulting.com/ADODataTypeEnum.htm

Does not answer all your questions, ask.
0
 

Author Comment

by:poutses
ID: 13681798
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 1000 total points
ID: 13681922
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
 

Author Comment

by:poutses
ID: 13695935
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13791350
I am sorry, it looks like I overlooked this comment.  Is this now fully resolved?
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question