Hello All and thank you in advance.
I am attempting to pass 3 string values to a function to automate filling a series of combo boxes on a form based off of information stored on several tables within a database..
This is the Call:
VB Code:
FillForm("AcolumnName","AtableName","ComboBoxtoFill")
The problem is the Underlined Item within code.
I am not sure of how to translate the Comboboxname from a string to an object im assuming.
I HAVE already attempted to pass the value as an object "
.......,ByVal cboBox As Object.....
But still recived an error at said location but no underline appeard on cbobox in code. So again im stumped. Eventualy there will be 5 or 6 calls to use this function on the Form.
VB Code:
Private Function FillForm(ByVal [B]column[/B] As String, ByVal [B]table[/B] As String, ByVal [B]cbobox[/B] As String) Dim myconn As SqlConnection Dim mycmd As SqlCommand Dim myread As SqlDataReader Dim output As String Dim outputInt As String myconn = New SqlConnection (Bla,Bla,Bla) myconn.Open() mycmd = myconn.CreateCommand() mycmd.CommandText = ("select " & [B]column[/B] & " from " & [B]table[/B]) myread = mycmd.ExecuteReader() While myread.Read() output = output & myread.GetString(0) [U][B]cbobox[/B].[/U]Items.Add(output) output = "" End While myread.Close() myconn.Close() cboLocation.SelectedIndex = 1 End Function




Reply With Quote