Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2008, 01:11 AM
Registered User
 
Join Date: Jun 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Gini
Default Query about code

The code below is for the combo box to retrieve items from the database. But now the problem I face is in the

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox.(from the code).


For the

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox,

the error is 'CatCodeComboBox is already declared as 'FriendWithEvents CatCodeComboBox As System.Windows.Forms.ComboBox' in this class. I do not know why this error has popped up and how do I solve it?


Code:
Imports System.Windows.Forms.DataGrid

Imports System.Data

Imports System.Data.SqlClient

Public Class InventoryMainForm

Private CatCodeDesc As String

Private CatCode As String

Private WarehouseLocation As String

Private Warehouse As String

Private UOMCode As String

Private subcatcode As String

Private subcat1code As String

Private subcat2code As String

Private subcat3code As String

Private AddNew As Boolean

Dim DQcheck As New SqlCommand

Dim DHcheck As New SqlDataAdapter

Dim DScheck As New DataSet

Dim Dvcheck As New DataView

InitializeComboBox()

 

'Declare CatCodeComboBox as combo box

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox

' 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

Dim connString As String = "server = 192.168.1.23;" + "integrated security = SSPI;" + "database = LBB"

Dim conn As New SqlConnection(connString)

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
 
Old June 23rd, 2008, 09:58 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Search for all occurences of "Friend WithEvents CatCodeComboBox" You can only have one instance of that statement. Check every box that will cause the search to include more areas: whole project, include hidden text, etc.

This statement should be generated by the form designer. If you are adding this statement through other means, you are going to run into troubles (even if you didn't set out to do that).





Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down List Code Query rsm42 ASP.NET 1.0 and 1.1 Basics 1 July 4th, 2007 02:22 PM
Code Query rsm42 ASP.NET 1.0 and 1.1 Basics 3 April 16th, 2007 12:06 PM
code for insert query shabirmaher General .NET 1 August 8th, 2005 08:20 AM
code to copy a query recordset to a file Ivan Access VBA 9 October 31st, 2003 06:50 PM
Select Query Code stevewardau Access 4 July 9th, 2003 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.