4 Replies - 2202 Views - Last Post: 27 May 2015 - 07:13 PM Rate Topic: -----

#1 nimz143   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 06-March 15

Error "Fill: SelectCommand.Connection property has not been initia

Posted 25 May 2015 - 09:27 PM

Hi all !

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

 
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

    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? :'(

Is This A Good Question/Topic? 0
  • +

Replies To: Error "Fill: SelectCommand.Connection property has not been initia

#2 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 396
  • View blog
  • Posts: 1,672
  • Joined: 07-September 13

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

Posted 26 May 2015 - 01:08 AM

Hello:

I am unsure what this object is, i am guessing that its your custom class that just managers your database transactions.

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


That being said i would assume the error is coming from within this routine. it seems you are not setting the connection to the select command.
ds = DHHConn.RunSPReturnDS("sp_Path_ID", New SqlParameter("@M_C", DeletePathID))

Was This Post Helpful? 0
  • +
  • -

#3 nimz143   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 06-March 15

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

Posted 26 May 2015 - 10:38 PM

Hi maceysoftware :)/>/>/>/>/>/>

Yessss! This code are use for manage my database transactions

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


Actually, i has another class namely as DRConnection that stored all the function for this DRConnection to open and close the connection. I don't has any idea where to fixed this error.

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).

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

 ds = DHHConn.RunSPReturnDS("sp_Path_ID", New SqlParameter("@M_C", DeletePathID)) 


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.

example as show on the attachments below.


My problem now :

1. i'm not be able to compare this data
2. i get this error Fill: SelectCommand.Connection property has not been initialized.

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 27 May 2015 - 02:00 AM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 396
  • View blog
  • Posts: 1,672
  • Joined: 07-September 13

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

Posted 27 May 2015 - 12:48 AM

Within the class: DRConnection - how does it specify the connection string? maybe post the code of it doing this as that might be useful.

Also post the code for RunSPReturnDS routine. we maybe able to spot where your going wrong however there is nothing within the code you have posted which will return that error.
Was This Post Helpful? 0
  • +
  • -

#5 nimz143   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 06-March 15

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

Posted 27 May 2015 - 07:13 PM

Hi maceysoftware.


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

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


Anyway, thank you for your guide ! :)/>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1