แก้ไขตรงส่วนนี้ยังไงครับ ExecuteReader: Connection property has not been initialized.'


code
Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
        If e.RowIndex = -1 Then Exit Sub

        employeeid = DataGridView1.Rows.Item(e.RowIndex).Cells(0).Value.ToString()
        Dim sqlAuth As String

        'sqlAuth = "SELECT cl_province,cl_position,cl_emp,cl_cus,cl_product,cl_pro_type,cl_brand,cl_unit,cl_sup,cl_cus_sale,cl_sup_buy FROM claim WHERE (e_id=@e_id)"

        sqlAuth = "SELECT  cl_province,cl_shop,cl_employee,cl_customer,cl_type,cl_product,cl_color,cl_brand,cl_size,cl_unit,cl_supplier,cl_supplier_product,cl_purchase,cl_receive,cl_sale,cl_reemp,cl_recus,cl_repur,cl_rereceive,cl_resale,cl_repro,cl_retop5,cl_claim"
        sqlAuth &= "FROM claim WHERE (employeeid=@employeeid)"

        With dc

            .CommandText = sqlAuth
            .CommandType = CommandType.Text

            .Parameters.Clear()
            .Parameters.Add("@employeeid", SqlDbType.VarChar).Value = employeeid

            dr = cmd.ExecuteReader
            If dr.HasRows Then
                With dr
                    .Read()
                    cl_province = .GetString(.GetOrdinal("cl_province"))
                    Cl_shop = .GetString(.GetOrdinal("cl_shop"))
                    cl_employee = .GetString(.GetOrdinal("cl_employee"))
                    cl_customer = .GetString(.GetOrdinal("cl_customer"))
                    cl_type = .GetString(.GetOrdinal("cl_type"))
                    cl_color = .GetString(.GetOrdinal("cl_color"))
                    cl_brand = .GetString(.GetOrdinal("cl_brand"))
                    cl_size = .GetString(.GetOrdinal("cl_size"))
                    cl_unit = .GetString(.GetOrdinal("cl_unit"))
                    cl_product = .GetString(.GetOrdinal("cl_product"))
                    cl_supplier = .GetString(.GetOrdinal("cl_supplier"))
                    cl_supplier_product = .GetString(.GetOrdinal("cl_supplier_product"))
                    cl_purchase = .GetString(.GetOrdinal("cl_purchase"))
                    cl_receive = .GetString(.GetOrdinal("cl_receive"))
                    cl_sale = .GetString(.GetOrdinal("cl_sale"))
                    cl_reemp = .GetString(.GetOrdinal("cl_reemp"))
                    cl_recus = .GetString(.GetOrdinal("cl_recus"))
                    cl_repur = .GetString(.GetOrdinal("cl_repur"))
                    cl_rereceive = .GetString(.GetOrdinal("cl_rereceive"))
                    cl_resale = .GetString(.GetOrdinal("cl_resale"))
                    cl_repro = .GetString(.GetOrdinal("cl_repro"))
                    cl_retop5 = .GetString(.GetOrdinal("cl_retop5"))
                    cl_claim = .GetString(.GetOrdinal("cl_claim"))
                End With
            Else
                cl_province = ""
                'ClearAll()
            End If
        End With
        dr.Close()

        If cl_province = "1" Then
            Check_province.Checked = True
        Else
            Check_province.Checked = False
        End If

        If cl_employee = "1" Then
            Check_employee.Checked = True
        Else
            Check_employee.Checked = False
        End If
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่