Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
As mention on the title above, i got an error

Fill: SelectCommand.Connection property has not been initialized

Anyone here have any idea or suggestion on how to solve this error?

My code (.aspx.vb) for this program

VB
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim i As Integer
        Dim result As DataSet
        Dim hypID As HyperLink
        Dim chkRemove As New CheckBox
        Dim clsPath As New Path()
        Try
            For i = 0 To grdPath.Rows.Count - 1
                chkRemove = DirectCast(grdPath.Rows(i).FindControl("chkRemove"), CheckBox)
                hypID = DirectCast(grdPath.Rows(i).FindControl("hypID"), HyperLink)
                If chkRemove.Checked Then
                    result = clsPath.getComparedPathID(chkRemove.Text)
                End If
            Next i
            lblErrorMessage.Text = "Paths delete successfully."
            BindGrid("%", "%", drpArea.SelectedValue, drpType.SelectedValue)
        Catch ex As Exception
            lblErrorMessage.Text = ex.Message
        End Try
    End Sub



And my .vb code is

VB
Public Function getComparedPathID(ByVal DeletePathID As String) As DataSet
        Dim DHHConn As New DRConnection("", "")
        Dim ds As DataSet
        Try
            ds = DHHConn.RunSPReturnDS("sp_Path_ID", New SqlParameter("@M_C", DeletePathID))
            Return ds
        Catch ex As Exception
            LogManager.WriteLog(ex.Message)
            Throw New Exception(ex.Message)
        Finally
            DHHConn.CloseConnection()
        End Try
    End Function 


Anyone here who's willing to help me? :'(
Posted
Comments
Sascha Lefèvre 26-May-15 0:27am    
You're using some custom database-access code there. DRConnection isn't a class that I've heard of yet. I don't think anyone will be able to help you unless you can either post the source of that class or a link to where you got it from.

The best hint I can give you: Take a look at the parameters for the constructor of DRConnection for which you provided just empty strings. You might need to provide "something more useful" there. And: If you have some other code in your program that already accesses the database successfully, compare it to this one.
apple blue 27-May-15 0:34am    
See my posting below :)
ArunRajendra 26-May-15 0:31am    
Its clear that the connection is not intialiazed. You need to put the code where the connection is being established.
apple blue 27-May-15 0:35am    
See my posting below :)
ArunRajendra 27-May-15 2:17am    
Do you have where this is working. If it is your code then you should be able to put the break point and check the connection object is propertly intialized.

1 solution

Hi Sascha Lefèvre and ArunRajendra :)


I'm success to solved this error ! I added the parameter on this line :

VB
Dim DHHConn As New DRConnection("", "DHHConn")


Anyway, thanks for help :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900