Sql Server Custom code Issue in SSRS

Hi there:
  In the Code tab in Report Properties, I have the following code:

Function DBConnect() As System.Data.SqlClient.SqlConnection
        Dim connectionstring As String
        connectionstring = "server=lafap; database=astea8l; uid=re; pwd=v8;"  
        Dim cn As New System.Data.SqlClient.SqlConnection(connectionstring)
        Return cn
End Function

Function test() as String
    Dim cn As New System.Data.SqlClient.SqlConnection
    cn.Open()
    cn.Close()
    return "Connected"
END Function

Also , in the reference tab, I've referenced the System.Data.
in the layout, I put =code.test() into one of the table field. And SSRS gives me the following error:

The value expression for the textbox textbox4 contains an error: The ConnectionString property has not been initialized.

Does someone have any idea how to get rid of this error?
 Also any recommendations on the debug env. for Custom Code?

 Thanks a lot

 Hui
HuiShiAsked:
Who is Participating?
 
Chris LuttrellConnect With a Mentor Senior Database ArchitectCommented:
Aren't you missing the call to your DBConnect() function?  maybe
Dim cn As System.Data.SqlClient.SqlConnection
cn = DBConnect()
0
 
Nathan RileyFounderCommented:
Looks like it's not working because your not able to connect to the sql server.  Look here:

http://forums.asp.net/p/983330/1262860.aspx
or
http://forums.asp.net/t/994521.aspx
0
 
HuiShiAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.