473,379 Members | 1,216 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,379 software developers and data experts.

Common procedures for executing all stored procedure

Hi all
I got problem regarding executing all stored procedure through
common procedures where we have different parameter with different
names, type and data type
The Function is as follows

Where strProcString is procedure name and strParamString is all
parameters concatenated by @

Public Function CeateDataSetSQL(ByVal strProcString As String, ByVal
ByVal strParamString As String) As DataSet
Dim dsLIS As DataSet
Dim Varr As System.Array
Dim Varr2 As System.Array
Dim intNoOfParameters As Integer
Dim j As Integer
If Not IsConnectionOpen Then
RaiseEvent ConnectionStatus("Connecting to SQL Server")
End If
Try

Dim conDatabase As New SqlConnection(strConnection)
Dim cmdCommand As New SqlCommand(strProcString,
conDatabase)
cmdCommand.CommandType = CommandType.StoredProcedure

dsLIS = New DataSet
sdaLISAdapter = New SqlDataAdapter(cmdCommand)
Varr = Split(strParamString, "@")
intNoOfParameters = UBound(Varr)

For j = 1 To intNoOfParameters
cmdCommand.Parameters.Add(New SqlParameter).Value =
CType(Varr.GetValue(j), String)
Next j

Me.sdaLISAdapter.Fill(dsLIS, "Result")
Catch ex As Exception

MsgBox(Err.Number & vbNewLine & Err.Description)

End Try

Return dsLIS

End Function

Where BOLD code give Error as parameter1 not present in given stored
procedure

Dec 24 '05 #1
1 1449
Hi,

When you add a parameter to a sqlcommand you need to provide the
parameter name and value.

cmdHit.Parameters.Add("@Id", strId) ' use addwithvalue for vs 2005

Ken
-------------------------
"A1 Ronen" <ro*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi all
I got problem regarding executing all stored procedure through
common procedures where we have different parameter with different
names, type and data type
The Function is as follows

Where strProcString is procedure name and strParamString is all
parameters concatenated by @

Public Function CeateDataSetSQL(ByVal strProcString As String, ByVal
ByVal strParamString As String) As DataSet
Dim dsLIS As DataSet
Dim Varr As System.Array
Dim Varr2 As System.Array
Dim intNoOfParameters As Integer
Dim j As Integer
If Not IsConnectionOpen Then
RaiseEvent ConnectionStatus("Connecting to SQL Server")
End If
Try

Dim conDatabase As New SqlConnection(strConnection)
Dim cmdCommand As New SqlCommand(strProcString,
conDatabase)
cmdCommand.CommandType = CommandType.StoredProcedure

dsLIS = New DataSet
sdaLISAdapter = New SqlDataAdapter(cmdCommand)
Varr = Split(strParamString, "@")
intNoOfParameters = UBound(Varr)

For j = 1 To intNoOfParameters
cmdCommand.Parameters.Add(New SqlParameter).Value =
CType(Varr.GetValue(j), String)
Next j

Me.sdaLISAdapter.Fill(dsLIS, "Result")
Catch ex As Exception

MsgBox(Err.Number & vbNewLine & Err.Description)

End Try

Return dsLIS

End Function

Where BOLD code give Error as parameter1 not present in given stored
procedure

Dec 24 '05 #2

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

Similar topics

0
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
1
by: Eugene Anthony | last post by:
Method 1: set rs = Server.CreateObject("ADODB.Recordset") objConn.usp_RetrieveCategories rs Method 2: set rs = objConn.Execute("usp_RetriveCategories") Which method is considered to...
1
by: Anthony Robinson | last post by:
I'm executing a stored procedure and getting the SQL0440N No authorized routine named "AMROBI2.CREATEAIMCONNECTION" of type "PROCEDURE " having compatible arguments was found. The schema...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
1
by: Alex | last post by:
Hi all, Just been dabbling with java stored procedures and I'm having problems replacing System: db2 8.1.4 on RH 7.1 linux system 1). Look at java jdbc samples as supplied with db2 and run...
5
by: Rhino | last post by:
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in Windows/Unix/Linux and how I can control that behaviour. Some documentation in the manuals is confusing the issue...
1
by: esmith2112 | last post by:
We all of a sudden find ourselves in dire straits, because we have one of those mysteries where everything used to work, and apparently, all of a sudden everything went to pot just in time for a...
0
by: billmiami2 | last post by:
Perhaps many of you MS Access fanatics already know this, but it seems that stored procedures and views are possible in Jet. I thought I would leave this message just in case it would help anyone....
2
by: kanda | last post by:
Hello. I am developing the application (VBA&ODBC, to be exact) which periodically calls the stored procedures in the IBM DB2. A few of the procedures require executing with isolation level RR (...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.