hafizhin.rosyiid 0 Newbie Poster

help me i want get data from combobox into single datagridview forecasting
i have 3 table
table 1 = Jenis with 3 column = IDPemakaian,JenisData, JenisPelanggan
table 2 = Periode with 6 column = Nomor, IDPemakaian, JenisData, Periode, Tahun, Jumlah
table 3 = Pelanggan with 6 column = Nomor, IDPemakaian, JenisData, KelompokPelanggan, Tahun, Jumlah

this my source

Imports System.Data
Imports System.Data.SqlClient

Public Class FormARIMA

    Private Sub Btn_Menu3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Menu3.Click
        FormMenuUtama.Show()
        Me.Hide()
    End Sub

    Private Sub Btn_Data2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Data2.Click
        FormDataPemakaian.Show()
        Me.Hide()
    End Sub

    Private Sub Btn_Exit3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Exit3.Click
        Me.Close()
    End Sub

    Private Sub Pasif()
        Cb_Periode.Enabled = False
        Cb_Pelanggan.Enabled = False
        Cb_Kelompok.Enabled = False
    End Sub

    Private Sub Rb_Pelanggan_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rb_Pelanggan.CheckedChanged

        If Rb_Pelanggan.Checked = True Then

            'Call readPelanggan()
            'Call readKelompok()
            'Call AktifPelanggan()
            Cb_Kelompok.Enabled = True
            Cb_Pelanggan.Enabled = True
            Cb_Periode.Enabled = False
        End If
    End Sub

    Private Sub Rb_Periode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rb_Periode.CheckedChanged

        If Rb_Periode.Checked = True Then

            Call readPeriode()
            'Call AktifPeriode()
            Cb_Periode.Enabled = True
            Cb_Pelanggan.Enabled = False
            Cb_Kelompok.Enabled = False
        End If

    End Sub

    Private Sub readPeriode()
        Try
            SqlConnection1.Open()
            Dim cmd As New SqlCommand("SELECT DISTINCT JenisData FROM Periode", SqlConnection1)
            Dim baca As SqlDataReader = cmd.ExecuteReader
            While baca.Read()
                Cb_Periode.Items.Add(baca("JenisData").ToString)
            End While
            baca.Close()
            cmd.Dispose()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            SqlConnection1.Close()
        End Try

    End Sub


    Private Sub FormARIMA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Pasif()

    End Sub


    Private Sub Cb_Periode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cb_Periode.SelectedIndexChanged
        Try
            SqlConnection1.Open()
            Dim cmd As New SqlCommand("SELECT * FROM Periode WHERE JenisData = '" & Cb_Periode.SelectedItem & "'", SqlConnection1)
            Dim baca As SqlDataReader = cmd.ExecuteReader
            While baca.Read()

                DataGridView1.Rows(0).Cells(0).Value = baca("JenisData").ToString
                DataGridView1.Rows(0).Cells(1).Value = baca("Periode").ToString
                DataGridView1.Rows(0).Cells(2).Value = baca("Tahun").ToString
                DataGridView1.Rows(0).Cells(3).Value = baca("Jumlah").ToString
            End While
            baca.Close()
            cmd.Dispose()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            SqlConnection1.Close()
        End Try
    End Sub
End Class

and this is link the picture

Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.