473,326 Members | 2,110 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,326 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 15042
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.