?
Solved

VB.net combo box

Posted on 2014-07-23
2
Medium Priority
?
283 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 2000 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

741 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