Results 1 to 7 of 7

Thread: [RESOLVED] Error "Fill: SelectCommand.Connection property has not been initialized"

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    Resolved [RESOLVED] Error "Fill: SelectCommand.Connection property has not been initialized"

    Hi all.

    I am using VS 2008 and SQL Server Management Studio 2008.

    As mention on the title above, i got an error : Fill: SelectCommand.Connection property has not been initialized
    This error occur after i debug my program and try to delete the Path ID that i want .

    My code (.aspx.vb) for this program

    Code:
     
    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

    Code:
    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
    This are used for open and close the connection.
    Code:
     Dim DHHConn As New DRConnection("", "")


    DRConnection
    is a class.

    Actually, this program works like this :

    1. user will choose path ID (retrieve all this data from table TPATH) that they want to delete.
    2. before the path ID would be delete, it will compare this path ID from table TTENS of database SDO and table TPATH of database SDO where this two table share the same column namely as M_C.
    3. this comparing method was write in Stored Procedure(SP).
    4. after done compared, then if path ID that user choose are not in table TTENS so, the path ID can be delete. But if path ID choose by user are in table TTENS, so the path ID cannot be delete.


    Name:  Capture2.PNG
Views: 3108
Size:  5.0 KB

    Code for my Stored Procedure :
    Code:
    CREATE PROCEDURE [dbo].[sp_Path_ID] @M_C varchar(20)
    AS
    BEGIN
        SELECT M_C FROM [dbo].[TPATH]
        WHERE M_C  NOT IN (SELECT M_RTE_C FROM [dbo].[TTENS])
        and M_C = @M_C
    END
    and here the line where i'm call my SP
    Code:
     ds = DHHConn.RunSPReturnDS("sp_Path_ID", New SqlParameter("@M_C", DeletePathID))


    Anyone here know how to solve this error? where i should fixed this error?

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: Error "Fill: SelectCommand.Connection property has not been initialized"

    What the error is telling you is that a Command object you are using does not have a database connection associated with it and there fore cannot run whatever SQL or Stored Procedure you are asking it to.

    However you have not posted the code for that bit so i cant tell you exactly where !!!

    We could do with seeing this method - RunSPReturnDS

    And knowing what
    Code:
    Dim DHHConn As New DRConnection("", "")
    expects as Arguments ???

    You passing in to blank arguments, could either one of them expect the connection string ?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    Re: Error "Fill: SelectCommand.Connection property has not been initialized"

    Hi NeedSomeAnswers

    Thanks a lot for your help. I'm able to figure out where its the error possibly occur.

    Yes! I'm passing in the blank arguments. After realize that, I add up the parameter into it

    from this code :

    Code:
     Dim DHHConn As New DRConnection("", "")
    to this code :

    Code:
    Dim DHHConn As NEw DRConnection("", "DDH_CONN")
    Now, the error was gone! Thank you

  4. #4
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: Error "Fill: SelectCommand.Connection property has not been initialized"

    No problem,

    if your happy your question has been answered then please set this thread as Resolved using the Thread tools
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    Re: Error "Fill: SelectCommand.Connection property has not been initialized"

    Hi NeedSomeAnswers !

    Done marking resolved for this thread

    But, one more question. Its there any thread for SQL Server? I want to ask regarding to my SQL problem.

    If yes, may I know which thread that I can join to ask about this SQL problem

    Thanks for your help!

  6. #6
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: [RESOLVED] Error "Fill: SelectCommand.Connection property has not been initialize

    Yes well there is a forum,

    post your question in the Database Development forum as a new Thread and state you are using SQL Server !!!
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    Re: [RESOLVED] Error "Fill: SelectCommand.Connection property has not been initialize

    Alrite! Thank you NeedSomeAnswers

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width