473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

calling a Stored Procedure using ASP code

hello..i have to call a stored procedure from an ASP page which has an only input parameter and doesnt return any value..... and the code i wrote is as below..

Dim objConn
Dim objCmd

Set objConn= Server.CreateObject("ADODB.Connection")
Set objCmd= Server.CreateObject("ADODB.Command")
objConn.Open "Driver={SQL Server}; Server=66.66.666.666\test; Database=mydatabase; UID=myuser; PWD=mypwd;"
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = "my_test"
objCmd.CommandType = adCmdStoredProc
objCmd.Parameters.Refresh
objCmd.Parameters(0) = "test"
objCmd.Execute

i dont know much ASP and now its hitting a below error...please suggest me where am i going wrong..or tell me a good approach to get succeeded....

ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/myfolder/mypage.asp, line 49

thanks for any kind of help in advance..
Aug 1 '07 #1
4 15048
ilearneditonline
130 Expert 100+
Hope this helps
Expand|Select|Wrap|Line Numbers
  1.  Dim cmd 
  2. set cmd = Server.CreateObject("ADODB.Command")
  3. ' the connection could vary depending on your sql server.
  4. cmd.ActiveConnection = "Provider=SQLOLEDB.1; Password=mypwd; Persist Security Info=True; User Id=myuser; Initial Catalog=YourDatabase;Data Source=66.66.666.666\test;"
  5. cmd.CommandText = "my_test"
  6. cmd.CommandTimeout = 30
  7. cmd.CommandType =adCmdStoredProc
  8. cmd.Prepared = true
  9. ' the parametes are parameter in sproc, type, direction, size, value
  10. cmd.Parameters.Append cmd.CreateParameter("@TestParamId", adInteger, adParamInput, 20, "1" )
  11. cmd.Execute()
  12.  
Aug 1 '07 #2
Hope this helps
Expand|Select|Wrap|Line Numbers
  1.  Dim cmd 
  2. set cmd = Server.CreateObject("ADODB.Command")
  3. ' the connection could vary depending on your sql server.
  4. cmd.ActiveConnection = "Provider=SQLOLEDB.1; Password=mypwd; Persist Security Info=True; User Id=myuser; Initial Catalog=YourDatabase;Data Source=66.66.666.666\test;"
  5. cmd.CommandText = "my_test"
  6. cmd.CommandTimeout = 30
  7. cmd.CommandType =adCmdStoredProc
  8. cmd.Prepared = true
  9. ' the parametes are parameter in sproc, type, direction, size, value
  10. cmd.Parameters.Append cmd.CreateParameter("@TestParamId", adInteger, adParamInput, 20, "1" )
  11. cmd.Execute()
  12.  
i have made my code as below according to ur code....


Dim cmd
set cmd = Server.CreateObject("ADODB.Command")
' the connection could vary depending on your sql server.
cmd.ActiveConnection = "Provider=SQLOLEDB.1; Password=mypwd; Persist Security Info=True; User Id=myid; Initial Catalog=mydb;Data Source=66.66.666.666\test;"
cmd.CommandText = "myprocedure"
cmd.CommandTimeout = 30
cmd.CommandType =adCmdStoredProc
cmd.Prepared = true
' the parametes are parameter in sproc, type, direction, size, value
cmd.Parameters.Append cmd.CreateParameter("@description", adVarChar, adParamInput, 500, "test")
cmd.Execute()

but it still hitting an error as below....

ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/myfolder/mypage.asp, line 47 (line 47 is this one--->cmd.CommandType =adCmdStoredProc)


please help me out as to why is this giving this type of error.my procedure has only one input parameter whose length is also 500 which is of varchar(500) type.pleasereply back ASAP...thanks for ur help...
Aug 1 '07 #3
ilearneditonline
130 Expert 100+
i have made my code as below according to ur code....


Dim cmd
set cmd = Server.CreateObject("ADODB.Command")
' the connection could vary depending on your sql server.
cmd.ActiveConnection = "Provider=SQLOLEDB.1; Password=mypwd; Persist Security Info=True; User Id=myid; Initial Catalog=mydb;Data Source=66.66.666.666\test;"
cmd.CommandText = "myprocedure"
cmd.CommandTimeout = 30
cmd.CommandType =adCmdStoredProc
cmd.Prepared = true
' the parametes are parameter in sproc, type, direction, size, value
cmd.Parameters.Append cmd.CreateParameter("@description", adVarChar, adParamInput, 500, "test")
cmd.Execute()

but it still hitting an error as below....

ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/myfolder/mypage.asp, line 47 (line 47 is this one--->cmd.CommandType =adCmdStoredProc)


please help me out as to why is this giving this type of error.my procedure has only one input parameter whose length is also 500 which is of varchar(500) type.pleasereply back ASAP...thanks for ur help...
This is from Microsoft
You may want to try ..
Expand|Select|Wrap|Line Numbers
  1.  Dim cmd 
  2. set cmd = Server.CreateObject("ADODB.Command")
  3. ' the connection could vary depending on your sql server.
  4. cmd.ActiveConnection = "Provider=SQLOLEDB.1; Password=mypwd; Persist Security Info=True; User Id=myid; Initial Catalog=mydb;Data Source=66.66.666.666\test;"
  5. cmd.CommandText = "myprocedure"
  6. cmd.CommandTimeout = 30
  7. cmd.CommandType = 4 'same as adCmdStoredProc
  8. cmd.Prepared = true
  9. ' the parametes are parameter in sproc, type, direction, size, value
  10. cmd.Parameters.Append cmd.CreateParameter("@description", 200, 1, 500, "test")
  11. cmd.Execute()
Aug 1 '07 #4
finally it worked and am very much thankful to u....thanks a lot.....
Aug 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JN | last post by:
Hello, I'm having problem calling stored procedures from Visual FoxPro database. I got the following exception error: "System.Data.OleDb.OleDbException: Unrecognized command verb" It seems...
0
by: Mike | last post by:
Hi, I am trying to insert parameters into a stored procedure using DAAB (see code at the bottom of this post). I am getting the following error: Object reference not set to an instance of an...
2
by: Woody Splawn | last post by:
I am using SQL Server 2000 as the back-end. I have created a stored procedure in SQL server called usp_AddContract. This Stored procedure inserts a new contract into a contracts table. I have...
4
by: Jack | last post by:
Hi, I am trying to run an example code from a book. However I am getting the following error message: Number: -2147217900 Description: Syntax error or access violation Source: Microsoft OLE...
3
by: michelle | last post by:
I am trying to get an output value from a stored procedure using sqlDataSource in asp.net 2.0. But I only get a null value for the output. Can someone please help? The sqlDataSource: ...
14
by: krishna1412 | last post by:
Currently i am working in a project of report generation in MS ACCESS. The tables are in sql server 2000. I have to write stored proc in ms access. Illustration: I am having a stored proc...
4
by: eighthman11 | last post by:
I'm calling a stored procedure on a sql server from an access application. I just need the stored procedure to run I do not need any data returned from the stored procedure to my Access...
0
by: =?Utf-8?B?Qm95ZA==?= | last post by:
Hi, I am trying to find out how to call an SQL stored procedure ( with 5 parameters all input) from a c++ application. A simple sample would be most appreciated. A link to a simple sample would...
1
by: ssrirao | last post by:
Hi, I have a table in the database and I want to insert the values into this table by using JavaScript. Does anyone know how to execute the Sql stored procedure using Javascript. Thanks
6
Soniad
by: Soniad | last post by:
Hello, I am excecuting a stored procedure in my ASP page , it has one out parameter (@confirm) . after executing the procedure i want to retreive this out parameter and assign it to variable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.