Solved

VB.net combo box

Posted on 2014-07-23
2
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

737 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