Solved

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

Posted on 2004-04-07
1
3,690 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.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 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

19 Experts available now in Live!

Get 1:1 Help Now