User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 403,031 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,864 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 234 | Replies: 3
Reply
Join Date: Jun 2008
Posts: 16
Reputation: Aigini is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Aigini Aigini is offline Offline
Newbie Poster

Error in code

  #1  
Jun 20th, 2008
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
        
        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
Last edited by Aigini : Jun 20th, 2008 at 6:07 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 760
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 58
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: Error in code

  #2  
Jun 20th, 2008
where's your connString string?! the problem in it!
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Jun 2008
Posts: 1
Reputation: purushottamr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
purushottamr purushottamr is offline Offline
Newbie Poster

Re: Error in code

  #3  
Jun 20th, 2008
first declare connString as string variable
and assign connection string i.e database name and password path of that every thing.

Originally Posted by Aigini View Post
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
        
        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
Reply With Quote  
Join Date: Nov 2007
Location: ★ Jogja ★
Posts: 2,477
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Rep Power: 9
Solved Threads: 215
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Nearly a Posting Maven

Re: Error in code

  #4  
Jun 20th, 2008
you didn't make a connection to sql server..
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 10:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC