napravio sam neku vrstu poslovnog programa koji koristi SQL bazu podataka.
Korisnik se uloguje, unosi neke podatke koje program čuva u bazu podataka 'BAZA' u tabelu 'TABELA'.
Želeo bih da na stranici za login postavim combobox sa opcijama '2014. godina', '2015. godina' itd.
Ako korisnik odabere '2014. godina' program treba da korsiti 'TABELA2014' tj. da isčitava podatke iz te tabele kao i da snima podatke u tu tabelu. Isto tako ako izabere '2015. godina' da isčitava podatke iz te tabele kao i da snima podatke u tu tabelu.
Ovo je neki primer koji 'učitava podatke':
Code:
Public Function GetData() As DataView
Dim SelectQry = "SELECT rtrim(id)[ID],rtrim(delovodnik)[Delovodnik] from TABELA order by Delovodnik desc"
Dim SampleSource As New DataSet
Dim TableView As DataView
Try
Dim SampleCommand As New SqlCommand()
Dim SampleDataAdapter = New SqlDataAdapter()
SampleCommand.CommandText = SelectQry
SampleCommand.Connection = Connection
SampleDataAdapter.SelectCommand = SampleCommand
SampleDataAdapter.Fill(SampleSource)
TableView = SampleSource.Tables(0).DefaultView
Catch ex As Exception
Throw ex
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return TableView
End Function
Public Function GetData() As DataView
Dim SelectQry = "SELECT rtrim(id)[ID],rtrim(delovodnik)[Delovodnik] from TABELA order by Delovodnik desc"
Dim SampleSource As New DataSet
Dim TableView As DataView
Try
Dim SampleCommand As New SqlCommand()
Dim SampleDataAdapter = New SqlDataAdapter()
SampleCommand.CommandText = SelectQry
SampleCommand.Connection = Connection
SampleDataAdapter.SelectCommand = SampleCommand
SampleDataAdapter.Fill(SampleSource)
TableView = SampleSource.Tables(0).DefaultView
Catch ex As Exception
Throw ex
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return TableView
End Function
Ne znam na koji način da uradim da na osnovu onoga što je izabrano u combobox-u odabere odgovarjuću tabelu. Da li može da se koristi if uslov i neki primer?