This is a migrated thread and some comments may be shown as answers.

Show data in textbox in the footer using a userdefine class function

2 Answers 42 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 29 Oct 2010, 09:12 PM

Hello,

 

I am trying to create a textbox that reads APPLICATION NAME from a table and displays it in the footer of the report.

 

I have created a class with following code:


Public Class CVA_Rpt
  
Public Shared Function Get_Config_Item(ByVal Item_name As String) As String
  
Dim mySelectQuery As String = "SELECT Constant_Value from tbl_CVA_Config Where Constant_Name='" & Item_name & "'"
  
Dim myConnString As String = ConfigurationManager.ConnectionStrings("CVA_Reporting").ToString()
  
Dim myConnection As New SqlClient.SqlConnection(myConnString)
  
Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, myConnection)
  
myConnection.Open()
  
Dim myReader As SqlClient.SqlDataReader
  
myReader = myCommand.ExecuteReader()
  
' Always call Read before accessing data.
  
Get_Config_Item = ""
  
While myReader.Read()
  
Get_Config_Item = myReader.GetString(0)
  
End While
  
' always call Close when done reading.
  
myReader.Close()
  
' Close the connection when done with it.
  
myConnection.Close()
  
End Function
  
Public Shared Function Application_Name() As String
  
Application_Name = Get_Config_Item("APPLICATION_NAME")
  
'Application_Name = "CVA Reports"
  
End Function
  
End Class


During design time, I enter the following in a textbox of the footer:
= CVA_Reports.CVA_Rpt.Application_Name()

I get the following error when previewing the report:
An error has occurred while processing TextBox 'txtApp_Db_Name':
An error has occurred while executing function App_name(). Check InnerException for further information.
------------- InnerException -------------
Exception has been thrown by the target of an invocation.
------------- InnerException -------------
Object reference not set to an instance of an object.

Note: I testing the CVA_Reports.CVA_Rpt.Application_Name() using a ASP page and it returns the desired value.

How can fix this error ?  I have looked everywhere on how to fix this error.  I have no clue. Please help.  THANK YOU!

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 29 Oct 2010, 09:18 PM
Sorry I posted the wrong error message.  The error message I am getting is below
An error has occurred while processing TextBox 'txtApp_Db_Name':
The expression contains object 'CVA_Appeal_Summary' that is not defined in the current context.
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 01 Nov 2010, 12:51 PM
I don't see CVA_Appeal_Summary object anywhere in the code you provided - have you missed to paste the whole thing? Paste the relevant code here and hopefully somebody would point you to the problem.

Cheers
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Massimiliano Bassili
Top achievements
Rank 1
Share this question
or