Hello community.
I am fairly new to programing and I started a small project with Visual Studio 2015, and created a small application in WinForms. The applications main purpose is database control via Microsoft Access, using a simple OleDbDataAdapter connection, using and SQL query to load up multiple lists in comboboxes.
My question is with the below queries if there is a better way to call it? As in to make a single query to run all 3 in the same procedure.
If this is the wrong section to post this, it can be moved.
Thank you in advance!
I am fairly new to programing and I started a small project with Visual Studio 2015, and created a small application in WinForms. The applications main purpose is database control via Microsoft Access, using a simple OleDbDataAdapter connection, using and SQL query to load up multiple lists in comboboxes.
My question is with the below queries if there is a better way to call it? As in to make a single query to run all 3 in the same procedure.
If this is the wrong section to post this, it can be moved.
Thank you in advance!
Retrieves some parameters from Access:
Try
Dim sql As String = ("SELECT param2 FROM tblParameters WHERE param1 LIKE '%' & 'TO252' & '%'")
Dim da As New OleDbDataAdapter(sql, conPara)
Dim ds As New DataSet
da.Fill(ds)
cbTO.ValueMember = "param2"
cbTO.DataSource = ds.Tables(0)
cbTO.SelectedIndex = -1
Catch ex As System.Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try
Try
Dim sql As String = ("SELECT param2 FROM tblParameters WHERE param1 LIKE '%' & '0402' & '%'")
Dim da As New OleDbDataAdapter(sql, conPara)
Dim ds As New DataSet
da.Fill(ds)
cbChip.ValueMember = "param2"
cbChip.DataSource = ds.Tables(0)
cbChip.SelectedIndex = -1
Catch ex As System.Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try
Try
Dim sql As String = ("SELECT param2 FROM tblParameters WHERE param1 LIKE '%' & 'orderreason' & '%'")
Dim da As New OleDbDataAdapter(sql, conPara)
Dim ds As New DataSet
da.Fill(ds)
cbOrder.ValueMember = "param2"
cbOrder.DataSource = ds.Tables(0)
cbOrder.SelectedIndex = -1
Catch ex As System.Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try