none
RDLC Custom Code Connect to SqlServer RRS feed

  • Question

  • Using RDLC local report, everything is fine I am trying to connect Sql server from custom code, but error throws at conn.Open(), no detail about the error, I have added all references.  Using expression "=Code.getOB(Fields!CATEGORYID)" to call it. Find code below
    Public Function getOB(categoryField as Field) As Decimal
    	     Dim comm As New System.Data.SqlClient.SqlCommand()
                Dim dtReader As System.Data.SqlClient.SqlDataReader
                Dim conn As New System.Data.SqlClient.SqlConnection()
                conn = New System.Data.SqlClient.SqlConnection("SERVER=test;Database=test;uid=sa;pwd=test;min pool size=5;max pool size=5000;connect timeout=20;")
                conn.Open()
                comm = New System.Data.SqlClient.SqlCommand("SELECT TOP 1 OPENINGBALANCEQTY FROM OPENINGBALANCE", conn)
                dtReader = comm.ExecuteReader()
                Dim d As Decimal = 0.0
                Do While dtReader.Read
                   d = dtReader(0)
                Loop
                dtReader.Close()
                conn.Close()
    Return d
    End Function


    Bala

    Thursday, July 4, 2013 4:29 AM

All replies