Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-07
1
Medium Priority
?
3,788 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
[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
1 Comment
 
LVL 26

Accepted Solution

by:
Alan Warren earned 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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