Solved

VB.net combo box

Posted on 2014-07-23
2
273 Views
Last Modified: 2014-08-30
Here is a code segment that runs successfully
In the part that is enclosed with ************************
I have a check box
When that box is checked we want to display a combo box that retrieves data from fccp.Resller.CompanyName
Could you help with the code to accomplish this?
Thanks in advance

Imports System.Data.SqlClient

Public Class CWActivityReport
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub ButtonRunReport_Click(sender As Object, e As EventArgs) Handles ButtonRunReport.Click
        GetAddedClients()
        GetDeletedClients()
        UpdatePanelReport.Update()

    End Sub

    Private Sub GetAddedClients()
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing

        Try
            FCCP_SQL = New SqlConnection
            FCCP_SQL.ConnectionString = ConfigurationManager.ConnectionStrings("FCCP_SQL").ConnectionString
            FCCP_DATAADAPTOR = New SqlDataAdapter
            dt = New DataTable
            'FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.CreatedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.Deleted = 0) AND (fccp_ResellerClients.CreatedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.CreatedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.CreatedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@StartDate", TextBoxStartDate.Text + " " + "0:00:00 AM")
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@EndDate", TextBoxEndDate.Text + " " + "11:59:59 PM")

            dt.Clear()
            FCCP_SQL.Open()
            FCCP_DATAADAPTOR.Fill(dt)

            RepeaterCreatedClients.DataSource = dt
            RepeaterCreatedClients.DataBind()

        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        Finally
            If Not FCCP_SQL Is Nothing Then FCCP_SQL.Dispose()
            If Not FCCP_DATAADAPTOR Is Nothing Then FCCP_DATAADAPTOR.Dispose()
            If Not dt Is Nothing Then dt.Dispose()
        End Try
    End Sub

    Private Sub GetDeletedClients()
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing

        Try
            FCCP_SQL = New SqlConnection
            FCCP_SQL.ConnectionString = ConfigurationManager.ConnectionStrings("FCCP_SQL").ConnectionString
            FCCP_DATAADAPTOR = New SqlDataAdapter
            dt = New DataTable
            FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.DeletedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.DeletedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            'FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.DeletedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.Deleted = 1) AND (fccp_ResellerClients.DeletedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@StartDate", TextBoxStartDate.Text + " " + "0:00:00 AM")
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@EndDate", TextBoxEndDate.Text + " " + "11:59:59 PM")

            dt.Clear()
            FCCP_SQL.Open()
            FCCP_DATAADAPTOR.Fill(dt)

            RepeaterDeletedClients.DataSource = dt
            RepeaterDeletedClients.DataBind()

        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        Finally
            If Not FCCP_SQL Is Nothing Then FCCP_SQL.Dispose()
            If Not FCCP_DATAADAPTOR Is Nothing Then FCCP_DATAADAPTOR.Dispose()
            If Not dt Is Nothing Then dt.Dispose()
        End Try
    End Sub

    Protected Sub SIP_CheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles SIP_CheckBox.CheckedChanged
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing
***************************************************************
        If SIP_CheckBox.Checked Then
            MsgBox("SIP check box was selected")

        End If
    End Sub
***************************************************************

End Class

Open in new window

0
Comment
Question by:tesla764
2 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 40215217
Is there a query that you are going to run when the checkbox is checked?  Once you have your query executed and you've filled your datatable, you need to set it as the DataSource for your combobox.

comboBox1.DataSource = dt
comboBox1.DisplayMember = "fieldName"
'If you have an ID you want associated with the display name add the line below
comboBox1.ValueMember = "fieldName"

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now