Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

776 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