?
Solved

Sql Server Custom code Issue in SSRS

Posted on 2009-04-20
3
Medium Priority
?
270 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:HuiShi
3 Comments
 
LVL 12

Expert Comment

by:Nathan Riley
ID: 24185566
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
 
LVL 27

Accepted Solution

by:
Chris Luttrell earned 2000 total points
ID: 24185951
Aren't you missing the call to your DBConnect() function?  maybe
Dim cn As System.Data.SqlClient.SqlConnection
cn = DBConnect()
0
 

Author Closing Comment

by:HuiShi
ID: 31572268
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question