Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

renamed stored proc parameters in a VB.NET WebApplication

Status
Not open for further replies.

wlrthjoilihjw

Programmer
Apr 18, 2005
2
0
0
DE
hi, all.

I use the CrystalReportViewr component in my VB.NET WebApplication to show reports created in CR9/CR10. Reports run against a SQL 200 DB using a stored procedure as a datasource.

In my reports I've renamed the stored proc parameters, e.g. @employee_id into Employee.

In my VB.NET code I use ApplyLogonInfo to set the new datasource information, because the name of production database differs from the name of the DB used to create reports. I've used the sample code from the Business Objects site.

After applying new logon information my parameter names seem to be OK: debugging through the ParameterFields collection I still see the "Employee" as parameter name. After that the report parameter prompt is displayed on the web page, and there's "@employee_id" instead of my human readable param name. After submitting of all necessary parameter values, the report crashes (.NET error message is displayed: "System.ArgumentException: Wrong Parameter" or so).

But it all works perfectly if I use the database with the same name as the report development DB has.

I never had such a problem with my old VB6 stand alone applications using RDC 9... I hope, there would be anyone knowing some approaches to solve the issue, otherwise I'll be probably placed in a mental health facility for crystal reports victims...

TIA
 
Hi
Here some code that might help you
Code snippet:

Before:

Public Function Delete(Optional ByVal Index _
As Integer = IS_MISSING_INT) As Boolean
Dim ErrorNum As Integer
Dim oDALEng As IOBPDA.IOBPConnection
Dim oCAccount As CAccount
Dim vParameters(0, 0) As Object
Dim inx As Integer
Dim SPName As String
Dim LowerLimit As Integer
Dim UpperLimit As Integer
If mcol.Count = 0 Then 'Nothing to Update
Delete = True
End If
'If Index is supplied then delete only the supplied record
If Not IsMissing(Index) Then
If Index < 1 Or Index > mcol.Count Then
Err.Raise'...
Else
LowerLimit = Index
UpperLimit = Index
End If
Else
LowerLimit = 1
UpperLimit = mcol.Count
End If
If Not SafeCreateObject(oDALEng, OBP_DA_CONNECTION, ErrorNum) Then
Err.Raise'...
End If
For inx = UpperLimit To LowerLimit Step -1
oCAccount = mcol.Item(inx)
If Not oCAccount.IsNew Then
'Delete from DB If Not New
ReDim vParameters(PARMUBOUND, 1)
With oCAccount
'Fill Parameter Array
.ClassStorage = True
vParameters(PARMNAME, 0) = _
PARMNAMESP_ACCOUNTACCOUNTID 'Name
'... set rest of parameters
.ClassStorage = False
End With
If Not oDALEng.Execute(SecurityToken, _
SP_D_ACCOUNT, vParameters) Then
Err.Raise'...
End If
End If
oCAccount = Nothing
'Remove from Collection
mcol.Remove((inx))
Next inx
Delete = True
Erase vParameters
End Function
After:

'Receives the Index parameter
Public Function Delete(ByVal Index As Integer) As Boolean

Dim LowerLimit As Integer
Dim UpperLimit As Integer
If Index < 1 Or Index > mcol.Count Then
Err.Raise'...
Else
LowerLimit = Index
UpperLimit = Index
End If
Delete = Delete(LowerLimit, UpperLimit)
End Function

'Without parameter
Public Function Delete() As Boolean
Dim LowerLimit As Integer
Dim UpperLimit As Integer
LowerLimit = 1
UpperLimit = mcol.Count
Delete = Delete(LowerLimit, UpperLimit)
End Function

'Extracted Delete method with lower and upper limit parameters is private
Private Function Delete(ByRef LowerLimit As Integer, _
ByRef UpperLimit As Integer)
Dim ErrorNum As Integer
Dim oDALEng As IOBPDA.IOBPConnection
Dim oCAccount As CAccount
Dim vParameters(0, 0) As Object
Dim inx As Integer
Dim SPName As String
If mcol.Count = 0 Then 'Nothing to Update
Delete = True
End If
If Not SafeCreateObject(oDALEng, OBP_DA_CONNECTION, ErrorNum) Then
Err.Raise'...
End If
For inx = UpperLimit To LowerLimit Step -1
' ... code to execute delete stored procedure – set rest of parameters
Next inx
Delete = True
End Function

' Change in ColAccount
' delegates
Public Function Delete(Optional ByVal Index _
As Integer = IS_MISSING_INT) As Boolean
If Not IsMissing(Index) Then
Delete = mPersistence.Delete(Index)
Else
Delete = mPersistence.Delete()
End If
End Function
Transmutation No 6: Replace Delegation with Inheritance



pgtek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top