Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Command Object

Author  Topic 

kensai
Posting Yak Master

172 Posts

Posted - 2002-02-16 : 07:09:40
Hi. I'm trying to try if my [url=http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=12882]problematic sp[/url] will work with Command. Since I don't know much about Command Object I'm just trying to do use some code I've found on this forum. But I'm having an error. Here's the code:

set objRS = Server.CreateObject("ADODB.Recordset")
Set objComm = Server.CreateObject("ADODB.Command")

objComm.ActiveConnection = objRS
objComm.CommandText = "ptemp"
objComm.CommandType = adCmdStoredProc

objComm.Parameters.Append objComm.CreateParameter("@isim", adVarChar, adParamInput, 50,"cmd1" )
objComm.Parameters.Append objComm.CreateParameter("@a", adInteger, adParamOutput,3000)
objComm.Execute

strReturn = Trim(cmd.Parameters ("@a").Value)

set objComm = Nothing
set objRS = Nothing

The error is:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/t/c.asp, line 19

It's the ActiveConnection line. What should I do for this?

kensai
Posting Yak Master

172 Posts

Posted - 2002-02-16 : 07:16:55
ok it works now :). I used this:

objComm.ActiveConnection = "Provider=SQLOLEDB;Data Source=SERVER;Initial Catalog=table;User ID=user;Password=pass"

Go to Top of Page

kensai
Posting Yak Master

172 Posts

Posted - 2002-02-16 : 07:43:45
Err, what should I use for text field type and size in CreateParameter method?

Go to Top of Page

kensai
Posting Yak Master

172 Posts

Posted - 2002-02-19 : 06:15:04
uhm, any ideas?

Go to Top of Page

jackstow
Posting Yak Master

160 Posts

Posted - 2002-02-19 : 07:02:57
Well, text and ntext datatypes don't seem to mix very well with Command object parameters. I had the same problem - http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=12651 - and there seem to be two solutions. Either select the text field into a recordset or datagrid using ADO/ADO.NET or split it up into several nvarchar fields.. The type for text in createparameter seems to be adVarChar, but you won't be able to use it as an output parameter..

Jack

Go to Top of Page

kensai
Posting Yak Master

172 Posts

Posted - 2002-02-21 : 15:43:14
oh I didn't knew that about text type. Thanks for pointing the topic.

Go to Top of Page
   

- Advertisement -