ADO Data type for SQL Server Text 
Author Message
 ADO Data type for SQL Server Text

I have a stored procedure in MS SQL Server that takes text as an argument..
What would be the equivalent in VB using ADO object to call the stored
procedure?

I'm trying to use the createparameter("arg1", ???, adParamInput, ???)

TIA
Jerry



Sun, 15 Feb 2004 01:43:43 GMT  
 ADO Data type for SQL Server Text
Hi,

Is it text datatype or char/varchar datatype?
Analog of text data type in ADO is
adLongVarChar/adLongVarWChar.
Analog of char/varchar datatype is adChar/adVarChar

But i am not sure if you can pass text field as a
parameter into SP using ADO. Probably you will need to use
Char/Varchar dadatype.

Val

Quote:
>-----Original Message-----
>I have a stored procedure in MS SQL Server that takes

text as an argument..
Quote:
>What would be the equivalent in VB using ADO object to
call the stored
>procedure?

>I'm trying to use the createparameter("arg1", ???,
adParamInput, ???)

>TIA
>Jerry

>.



Sun, 15 Feb 2004 02:06:26 GMT  
 ADO Data type for SQL Server Text
There are more than one way to implement this task:

One is to query the data source about the parameters of the stored
procedure by calling the Refresh function of the parameters collection of
command object. Sample code:

   Cmd1.ActiveConnection = Conn1
   Cmd1.CommandText = "sp_AdoTest"
   Cmd1.CommandType = adCmdStoredProc
   Cmd1.Parameters.Refresh
   Cmd1.Parameters(1).Value = "text for the parameter"
   Set Rs1 = Cmd1.Execute()

Another method is to explicitly create the parameter objects properties
using the CreateParameter function of the command object and Append
function of the parameters collection of the command object. Sample code:
   ...
   Set Cmd1 = New ADODB.Command
   Cmd1.ActiveConnection = Conn1
   Cmd1.CommandText= "sp_AdoTest"

   Set Param1 = Cmd1.CreateParameter(, adInteger, adParamReturnValue)
   Cmd1.Parameters.Append Param1

   Set Param2 = Cmd1.CreateParameter(, adInteger, adParamInput)
   Param2.Value = 10
   Cmd1.Parameters.Append Param2

   Set Param3 = Cmd1.CreateParameter(, adInteger, adParamOutput)
   Cmd1.Parameters.Append Param3

   Set Rs1 = Cmd1.Execute()

For more formation, please refer to the following article in Microsoft
Knowledge Base:
Title:HOWTO: Refresh ADO Parameters for a Stored Procedure  
http://support.microsoft.com/support/kb/articles/q174/2/23.asp



Sun, 15 Feb 2004 14:13:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ADO/SQL Server Data Types

2. ADO/SQL Server Data Types

3. Retrieving SQL Server Text data type in VB.NET

4. Problem reading Text data type from SQL Server

5. Problem reading Text data type from SQL Server

6. Accesssing SQL Server Text data types using RDO

7. FILE UPLOAD FROM ASP TO SQL SERVER TEXT DATA TYPE

8. SQL Server Text Data Type

9. SQL Server 'Text' Data Type Field

10. ADO, text driver - ADO picks wrong data type...

11. ADO, SQL Server, VB problem posted to the microsoft.public.data.ado group as well

12. ADO data types and vbasic data types mapping

 

 
Powered by phpBB® Forum Software