PC Review


Reply
Thread Tools Rate Thread

Common procedures for executing all stored procedure

 
 
A1 Ronen
Guest
Posts: n/a
 
      24th Dec 2005
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

 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      24th Dec 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Map Stored Procedure dependencies from ASP pages through methods to stored procedures dwilliams@newportgroup.com Microsoft Dot NET 6 18th Mar 2005 03:02 AM
Map Stored Procedure dependencies from ASP pages through methods to stored procedures dwilliams@newportgroup.com Microsoft ADO .NET 2 17th Mar 2005 12:47 PM
Executing Stored Procedures Nexus Microsoft Access ADP SQL Server 2 17th Sep 2004 10:22 PM
Error: Executing Stored Procedures-- Cannot Pass TimeStamp Values From sqlCommand Object Parameter to A SQL Stored Procedure =?Utf-8?B?VGVjaE1E?= Microsoft ADO .NET 3 17th Mar 2004 04:03 AM
Executing stored procedures Andy Williams Microsoft Access ADP SQL Server 2 7th Nov 2003 02:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 PM.