473,698 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem Calling Stored Procedure

Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my code.

Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString
("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO
Nov 21 '05 #1
6 1454
I don't work a lot with stored procedures but maybe if you declare your
parameters like this, it helps.

Dim objParam as SqlParameter
objParam = new
SqlParamete("@n ame",sqldbtype. Varchar,50,Para meterdirection. Input)
objParam.value = "yourvalue"
cmdCleanUncheck edSuites.parame ters.add(objPar am)

objParam = new SqlParameter
_("@name2",sqld btype.Varchar,5 0,Parameterdire ction.Input)
objParam.value = "yourvalue"
cmdCleanUncheck edSuites.parame ters.add(objPar am)

hth

greetz Peter
"Scott McNair" <sc**********@s fmco.takethispa rtout.com> wrote in message
news:Xn******** ***********@207 .46.248.16...
Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my code.
Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString ("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO

Nov 21 '05 #2
I don't know why your sproc is not running but I had a problem with a
sproc not apparently running and it turned out that there was an
exception generated and my code swallowed up the exception.

Is your code wrapped in a Try Catch? Or is there a try catch somewhere
that could be hit and the exception is not logged? Or if it is logged,
did you check wherever you log exceptions to see if there was one?
Just a thought

Nov 21 '05 #3
Scott, you could also put a SQL trace on the server (presuming this is SQL).
That will confirm the procedure is being called, and that he parameters and
their values are being correctly sent.

"Scott McNair" <sc**********@s fmco.takethispa rtout.com> wrote in message
news:Xn******** ***********@207 .46.248.16...
Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my
code.

Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString
("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO

Nov 21 '05 #4
Perhaps you want to take a look of this again:

http://support.microsoft.com/default...b;en-us;308049

chanmm
"Scott McNair" <sc**********@s fmco.takethispa rtout.com> wrote in message
news:Xn******** ***********@207 .46.248.16...
Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my
code.

Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString
("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO

Nov 21 '05 #5
Scott,
In your parameter list you define @PresentationID as an SqlDbType.Int
but in the SPROC definition it is a varchar(50). This will cause an error
in the SPROC.

Ron Allen
"Scott McNair" <sc**********@s fmco.takethispa rtout.com> wrote in message
news:Xn******** ***********@207 .46.248.16...
Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my
code.

Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString
("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO

Nov 21 '05 #6
Scott,
In your parameter list you define @PresentationID as an SqlDbType.Int
but in the SPROC definition it is a varchar(50). This will cause an error
in the SPROC.

Ron Allen
"Scott McNair" <sc**********@s fmco.takethispa rtout.com> wrote in message
news:Xn******** ***********@207 .46.248.16...
Hi all,

I'm having problems calling a stored procedure from within my code. If I
execute the SP manually from a Query Analyzer window it runs without a
hitch, but it seems it doesn't even fire when I try to run it from my
code.

Anyway, here's both the VB code and the stored procedure:

With cmdCleanUncheck edSuites
.Connection = cnSalesWiz
.CommandType = CommandType.Sto redProcedure
.CommandText = "prCleanUncheck edSuites"
.Parameters.Add ("@SuiteList ", SqlDbType.VarCh ar)
.Parameters.Add ("@Presentation ID", SqlDbType.Int)
.Parameters.Add ("@CheckString" , SqlDbType.VarCh ar)
.Parameters("@S uiteList").Valu e = Replace("'" & SQLEncode
(Request.Form(" SuiteList")) & "'", vbCrLf, ",")
.Parameters("@P resentationID") .Value = CInt(Request.Qu eryString
("ID"))
.Parameters("@C heckString").Va lue = Replace("'" & SQLEncode
(Request.Form(" SuiteID")) & "'", vbCrLf, ",")
'These next three lines run, so I know it's making it to here
Response.Write( .Parameters("@S uiteList").Valu e & "<br>")
Response.Write( .Parameters("@P resentationID") .Value & "<br>")
Response.Write( .Parameters("@C heckString").Va lue & "<br>")
.ExecuteNonQuer y()
End With
CREATE PROCEDURE prCleanUnchecke dSuites (
@SuiteList varchar(200),
@PresentationID varchar(50),
@CheckString varchar(8000) = ''
) AS
DELETE FROM tblItems
WHERE SuiteID IN (
SELECT SuiteID
FROM MasterSuites
WHERE SuiteNum In (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@SuiteList,',' )
) AND
SuiteID NOT IN (
SELECT LTRIM(RTRIM(Val ue))
FROM Common.dbo.spli t
(@CheckString,' ,')
)
) AND
PresentationID = @PresentationID
GO

Nov 21 '05 #7

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

Similar topics

6
6897
by: dw | last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." I've run the same stored procedure with the same exact list of arguments in Query Analyser in SQL Server, and it works. The page has the adovbs constants. Note that uspGetProperties is a stored procedure in SQL...
18
19477
by: Jarrod Morrison | last post by:
Hi All I was wondering if there is a way to call a stored procedure from inside another stored procedure. So for example my first procedure will call a second stored procedure which when executed will return one record and i want to use this data in the calling stored procedure. Is this possible ? Thanks in advance
2
9237
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
0
2400
by: Roman Prigozhin | last post by:
HI All, I have a problem with calling stored procedure in multithreaded environment. This procedure utilizes session table to collect data and cursor to return it back to java application . When 10 threads are trying to use the same stored procedure, once one of the thread finishes up and returns connection back to the pool I'm getting exception from all other 9 stored procedures : com.ibm.db2.jdbc.app.DB2DBException: SC_PE00003 in...
2
2136
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 tested the code in Enterprise Manager and it works correctly. At the time that I run the SP I pass a contract number and a SSN to the SP and it creates a new contract in the contracts table with a unique value in the ConNum field and SSN field. In...
4
6712
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 DB Provider for SQL Server SQLState: 42000
4
3991
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is limited to the first 100 rows. Data returned in result set columns is limited to the first 20...
4
17402
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 application but I do pass parameters from my Access application. What I have works fine and is attached below. But I have one question. Why do I need this line of code to execute the stored procedure. Set rst = qdf.OpenRecordset(dbOpenSnapshot) Here...
1
2971
by: amgupta8 | last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2. Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well). This is the original exception that I got before I tried any code modifications: java.io.IOException: invalid offset/length at...
0
8674
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
9157
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...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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
6518
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
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
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
2328
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.