Solved

How to use ADODB from VBA to retrieve / update SQL Server nvarchar, text, and ntext

Posted on 2004-04-07
1
3,684 Views
Last Modified: 2012-06-22
I'm enhancing a customer's application that has an Access 2002 front end mdb to a SQL Server back end. I use stored procedures to select and update data. Everything was working fine until I encountered some tables with large varchar, nvarchar, text, and ntext columns. In those cases I can't figure out what type to assign to my adodb parameters. For example, if I have as simple table with:

ID as indentity primary key
SVC as varchar(100)
LVC as varchar(4000)
SNVC as nvarchar(100)
LNVC as nvarchar(4000)
T1 as text
T2 as ntext

What does my VBA adodb command parameter look like for each of the above for a select stored procedure, i.e.

cmd.Parameters.Append .CreateParameter("@SVC", advarchar, adParamInput, 100)
cmd.Parameters.Append .CreateParameter("@LVC", ad?, adParamInput, ?)
cmd.Parameters.Append .CreateParameter("@SNVC", ad?, adParamInput, ?)
cmd.Parameters.Append .CreateParameter("@LNVC", ad?, adParamInput, ?)
cmd.Parameters.Append .CreateParameter("@T1", ad?, adParamInput, ?)
cmd.Parameters.Append .CreateParameter("@T2", ad?, adParamInput, ?)

Thx
0
Comment
Question by:rmk
1 Comment
 
LVL 26

Accepted Solution

by:
Alan Warren earned 250 total points
ID: 10779541
Hi rmk



ADO DataType Enum
http://www.able-consulting.com/ADODataTypeEnum.htm

' you can pass the value too as the last param, done the first one for you
dim sSVC as String
sSVC = "SomeString"
' or
' sSVC = me.sometextbox

cmd.Parameters.Append .CreateParameter("@SVC", adVarChar, adParamInput, 100, sSVC)
cmd.Parameters.Append .CreateParameter("@LVC", adVarChar, adParamInput, 4000)
cmd.Parameters.Append .CreateParameter("@SNVC", adVarWChar, adParamInput, 100)
cmd.Parameters.Append .CreateParameter("@LNVC", adVarWChar, adParamInput, 4000)
cmd.Parameters.Append .CreateParameter("@T1", adLongVarChar, adParamInput, 2147483647)
cmd.Parameters.Append .CreateParameter("@T2", adLongVarChar, adParamInput, 2147483647)


Alan
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now