Link to home
Start Free TrialLog in
Avatar of HuiShi
HuiShi

asked on

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
Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of Chris Luttrell
Chris Luttrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HuiShi
HuiShi

ASKER

thanks