This is my code to load data from a database(SQL Server 2000) into a combo box. I keep getting the error Name 'connString' not declared.(the highlighted section of the code). I've tried posing this error in Google search but there are no answers. I am working in a software development company, and this code is part of the system I am developing in that company.
'This method initializes the combo box in Item Category Level 1,
' adding data from the table inv_category but limiting the drop-down size
' to six rows so the combo box doesn't cover other controls when it expands.
Private Sub InitializeComboBox()
Me.CatCodeComboBox = New System.Windows.Forms.ComboBox
[B] Dim conn As New SqlConnection(connString)[/B]
Dim strSQL As String = "SELECT ict_code FROM inv_itemcategory"
Dim da As New SqlDataAdapter(strSQL, conn)
Dim ds As New DataSet
da.Fill(ds, "inv_itemcategory")
With CatCodeComboBox
.DataSource = ds.Tables("inv_itemcategory")
.DisplayMember = "ict_code"
.ValueMember = "ict_code"
.SelectedIndex = 0
End With
Me.CatCodeComboBox.Location = New System.Drawing.Point(95, 32)
Me.CatCodeComboBox.MaxDropDownItems = 5
Me.CatCodeComboBox.DropDownStyle = ComboBoxStyle.DropDown
Me.CatCodeComboBox.Name = "CatCodeComboBox"
Me.CatCodeComboBox.Size = New System.Drawing.Size(292, 21)
Me.CatCodeComboBox.TabIndex = 0
Me.Controls.Add(Me.CatCodeComboBox)
End Sub