473,803 Members | 3,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp script connected to sql server gives error

I have the following asp script which I am trying to run against sql server.

<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
<TITLE>Chapte r 12 - Command Object</TITLE>
</HEAD>
<BODY>
Receiving a Return Value FROM SQL Server<br><br>
<%
'Create and open the database object
Set objConn = Server.CreateOb ject("ADODB.Con nection")
set objcmd = Server.CreateOb ject("ADODB.Com mand")

sConnString = "Provider=SQLOL EDB.1;User ID=sa;password= abcd;Initial
Catalog=sailors ;Data Source = TESTSERVER"
objConn.Open sConnString
Set objcmd.ActiveCo nnection = objConn

'Declare the variables

Dim adCmdStoredProc
Dim adInteger
Dim adParamReturnVa lue
adCmdStoredProc = 4
adInteger = 3
adParamReturnVa lue = 4

'Create a parameter object

Set objParm = Server.CreateOb ject("ADODB.Par ameter")

'Set the command object properties

objCmd.CommandT ext = "{? = call up_select_count _of_boats}"
objCmd.CommandT ype = adCmdStoredProc
'Set the parameter and append it to the paramaters collection

Set objParm = objCmd.CreatePa rameter("Return ", adInteger,
adParamReturnVa lue,,0)
objCmd.Paramete rs.Append objParm
objCmd.Execute
Response.Write "There are " & objCmd.Paramete rs.Item("Return ").Value & "
Registered Boats Listed"

'Dereference object
Set objParm = Nothing
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing
%>

</BODY>
</HTML>

However, I am getting error message as follows:Microso ft OLE DB Provider for
SQL Server (0x80040E10)
No value given for one or more required parameters.
/beginaspdatabas e1/pg497b.asp, line 44
Line 44 is the objCmd.Execute

The stored associated stored procedure is:
CREATE PROCEDURE up_select_count _of_boats AS
DECLARE @count INT
SELECT @count = count(boatsid) FROM boats
Return @count
GO

I am not sure why I am getting error. Any suggestion/help is appreciated.
Thanks.

Dec 20 '05 #1
6 3500
Jack wrote:
objCmd.CommandT ext = "{? = call up_select_count _of_boats}"
Should be simply:
objCmd.CommandT ext = "up_select_coun t_of_boats"
objCmd.CommandT ype = adCmdStoredProc
'Set the parameter and append it to the paramaters collection

Set objParm = objCmd.CreatePa rameter("Return ", adInteger,
adParamReturnVa lue,,0)
objCmd.Paramete rs.Append objParm
objCmd.Execute
Should be
objCmd.Execute ,,128 '128=adExecuteN oRecords

However, I am getting error message as follows:Microso ft OLE DB
Provider for SQL Server (0x80040E10)
No value given for one or more required parameters.
/beginaspdatabas e1/pg497b.asp, line 44 You never set the Command's Activeconnectio n property to an open Connection
object.

Set objCmd.ActiveCo nnection=objCon n
....
objCmd.Execute ,,128
Line 44 is the objCmd.Execute

The stored associated stored procedure is:
CREATE PROCEDURE up_select_count _of_boats AS
DECLARE @count INT
SELECT @count = count(boatsid) FROM boats
Return @count
GO


It's not effecting anything here, but it's a good practice to inclued "SET
NOCOUNT ON" in all stored precedures to be executed via ADO:
CREATE PROCEDURE up_select_count _of_boats AS
SET NOCOUNT ON
....
go

This will prevent the sending of extra closed resultsets containing the
informational "x rows affected" messages.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 20 '05 #2
Thanks for the help Bob. I appreciate it. Now the code looks as follows:

<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
<TITLE>Chapte r 12 - Command Object</TITLE>
</HEAD>
<BODY>
Receiving a Return Value FROM SQL Server<br><br>
<%
'Instruct VBScript to ignore the error and continue with the next line of code
'On Error Resume Next

'Create and open the database object
Set objConn = Server.CreateOb ject("ADODB.Con nection")
set objcmd = Server.CreateOb ject("ADODB.Com mand")

sConnString = "Provider=SQLOL EDB.1;User ID=sa;password= abcd;Initial
Catalog=sailors ;Data Source = TESTSERVER"
objConn.Open sConnString
Set objcmd.ActiveCo nnection = objConn

'Declare the variables

Dim adCmdStoredProc
Dim adInteger
Dim adParamReturnVa lue
adCmdStoredProc = 4
adInteger = 3
adParamReturnVa lue = 4

'Create a parameter object

Set objParm = Server.CreateOb ject("ADODB.Par ameter")

'Set the command object properties

objCmd.CommandT ext = "call up_select_count _of_boats"
objCmd.CommandT ype = adCmdStoredProc
'Set the parameter and append it to the paramaters collection

Set objParm = objCmd.CreatePa rameter("Return ", adInteger,
adParamReturnVa lue,,0)
objCmd.Paramete rs.Append objParm
objCmd.Execute, ,128
Response.Write "There are " & objCmd.Paramete rs.Item("Return ").Value & "
Registered Boats Listed"

'Dereference object
Set objParm = Nothing
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing

%>

</BODY>
</HTML>

However, now I am getting a error stating the following:

Error Type: Microsoft OLE DB Provider for SQL Server (0x80040E14) Syntax
error or access violation which is at line 44 or the execute statement line.
Why is this happening now? Thanks.
"Bob Barrows [MVP]" wrote:
Jack wrote:
objCmd.CommandT ext = "{? = call up_select_count _of_boats}"


Should be simply:
objCmd.CommandT ext = "up_select_coun t_of_boats"
objCmd.CommandT ype = adCmdStoredProc
'Set the parameter and append it to the paramaters collection

Set objParm = objCmd.CreatePa rameter("Return ", adInteger,
adParamReturnVa lue,,0)
objCmd.Paramete rs.Append objParm
objCmd.Execute


Should be
objCmd.Execute ,,128 '128=adExecuteN oRecords

However, I am getting error message as follows:Microso ft OLE DB
Provider for SQL Server (0x80040E10)
No value given for one or more required parameters.
/beginaspdatabas e1/pg497b.asp, line 44

You never set the Command's Activeconnectio n property to an open Connection
object.

Set objCmd.ActiveCo nnection=objCon n
....
objCmd.Execute ,,128
Line 44 is the objCmd.Execute

The stored associated stored procedure is:
CREATE PROCEDURE up_select_count _of_boats AS
DECLARE @count INT
SELECT @count = count(boatsid) FROM boats
Return @count
GO


It's not effecting anything here, but it's a good practice to inclued "SET
NOCOUNT ON" in all stored precedures to be executed via ADO:
CREATE PROCEDURE up_select_count _of_boats AS
SET NOCOUNT ON
....
go

This will prevent the sending of extra closed resultsets containing the
informational "x rows affected" messages.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Dec 20 '05 #3
Jack wrote:
Thanks for the help Bob. I appreciate it. Now the code looks as
follows: <snip> objCmd.Execute, ,128

<snip>
objCmd.Execute ,,128


See the difference? :-)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 20 '05 #4
Bob,
Sorry for the screw up. I corrected the syntax and still I am getting the
same error as before. Any further hints?

"Bob Barrows [MVP]" wrote:
Jack wrote:
Thanks for the help Bob. I appreciate it. Now the code looks as
follows:

<snip>
objCmd.Execute, ,128

<snip>
objCmd.Execute ,,128


See the difference? :-)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Dec 20 '05 #5
It should work ...

You should try my free code generator available at
http://www.thrasherwebdesign.com/ind...s&hp=links.asp (here's the
download link:
http://www.thrasherwebdesign.com/dow...parameters.zip)

Oh wait, you still have the call keyword in the commandtext. Get rid of it.
It should simply be the name of the stored procedure ... nothing else:
objCmd.CommandT ext = "up_select_coun t_of_boats"
Jack wrote:
Bob,
Sorry for the screw up. I corrected the syntax and still I am getting
the same error as before. Any further hints?

"Bob Barrows [MVP]" wrote:
Jack wrote:
Thanks for the help Bob. I appreciate it. Now the code looks as
follows:

<snip>
objCmd.Execute, ,128

<snip>
objCmd.Execute ,,128


See the difference? :-)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 20 '05 #6
Thanks Bob. I am going to try this product by your recommendation. Best
regards.

"Bob Barrows [MVP]" wrote:
It should work ...

You should try my free code generator available at
http://www.thrasherwebdesign.com/ind...s&hp=links.asp (here's the
download link:
http://www.thrasherwebdesign.com/dow...parameters.zip)

Oh wait, you still have the call keyword in the commandtext. Get rid of it.
It should simply be the name of the stored procedure ... nothing else:
objCmd.CommandT ext = "up_select_coun t_of_boats"
Jack wrote:
Bob,
Sorry for the screw up. I corrected the syntax and still I am getting
the same error as before. Any further hints?

"Bob Barrows [MVP]" wrote:
Jack wrote:
Thanks for the help Bob. I appreciate it. Now the code looks as
follows:
<snip>
objCmd.Execute, ,128
<snip>
> objCmd.Execute ,,128

See the difference? :-)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Dec 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1608
by: Hameed Khan | last post by:
hi all, i am getting some problems with my first socket script. can any one of you point me why this is happening. the server script suppose to accept one connection at a time and send countdown to client connected to it from a function through a separate thread. and echo all the connections opened and closed. the client script is working fine. it echoes the countdown it recieve from server.
5
6307
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. However, I have a script that absolutely MUST finish one it's been started--is there a way to cause the entire script to execute, even if the client disconnects in the middle of the process? It doesn't matter if the script returns anything to the...
0
2047
by: Freebase | last post by:
Something changed recently on our W2K SP4 machine when we installed INTERSOLV ODBC software... the following script just opens a connection to an MS-Access DB, gets a record then tears down the connection <% tpl_ConnectString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=g:/inetpub/wwwroot/servers/xta_db/tpl.mdb" query = "select tpl_text from templates where tpl_name='showart_top'" response.buffer=false for i=1 to 100
12
2998
by: tshad | last post by:
I am not sure why I am getting this error: I have the following code I want to run from another include file that holds all my functions. functions.inc ************************************************************************************ <Script runat="Server"> Sub fnHeader(client As String) response.write("<!-- #include file = ../includes/staffingHeaders.inc -->")
8
7418
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to assign value form the object to text Box it gives error 'Object required' Dim strResponse As String strResponse = strResponse & "<script language=""JavaScript"">" & vbCrLf strResponse = strResponse & "var aForm; " & vbCrLf
21
8544
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript" src="NO JAVASCRIPT CAN BE USED HERE" /> So I am see'g If I can use eval todo something what I am doing I have tried almost everything, following is being last one
7
1705
by: muttu2244 | last post by:
Hi Everyone I want to run a python script in all the machines that are connected through local network and collect the information about that machine such as HDD size, RAM capacity(with number of slots) ,processer speed etc. But i want to run a script from just the server, so that it should start scripts in all other machines, and get their local machines information and dump the same information in some FTP.
0
1148
rajiv07
by: rajiv07 | last post by:
Hi to all this is the code i am using to do some task but it gives the following error.i am breaking my head why the error is coming please help me on this. The Error in log file. (2)No such file or directory: exec of '/var/www/cgi-bin/xone/query/store_login.pl' failed Premature end of script headers: store_login.pl The Script
5
3488
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() - after sending, a small summary html page is sent to the user with number sent, time taken and a simple navigation choice. Up to about 100 emails it all works fine - this takes the server about 27 secs . Any more than that and although the emails are...
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9566
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10300
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.