|
-
Jul 13th, 2006, 01:17 PM
#1
Thread Starter
New Member
[RESOLVED] Populating a comboBox with an ArrayList
Hi, I am trying to populate a ComboBox with the contents obtained within an ArrayList, but instead of putting the names held within the ArrayList, it writes "System.Collections.ArrayList" in the place of the desired names.
Could you take a look at my code and see where I am going wrong.
I am using vb.net 2002 version.
Any help is greatly appreciated.
Many thanks
John
This is the code for the function selectFieldNames :-
Code:
Public fieldNames As New ArrayList()
Public Function selectFieldNames(ByVal strSQL As String) As ArrayList
' select all field names from the selected table
sqlite_cmd.CommandText = (strSQL)
' Now the SQLiteCommand object can give us a DataReader-Object:
sqlite_datareader = sqlite_cmd.ExecuteReader()
While sqlite_datareader.Read()
Try
fieldNames.Add(sqlite_datareader("name"))
MessageBox.Show(sqlite_datareader("name"))
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End While
Return fieldNames
End Function
This is the code for populating the ComboBox :-
Code:
Private Sub frmCreateIndex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;")
dbConn.createSQLCommand()
Dim a As Integer
Try
dbConn.selectFieldNames("pragma table_info(test)")
For a = 0 To (dbConn.fieldNames.Count) - 1
cmbFieldIndex.Items.Add(dbConn.fieldNames)
Next a
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Last edited by Hack; Jul 24th, 2006 at 06:09 AM.
Reason: Added [RESOLVED] to thread title and green "resolved" checkmark
-
Jul 15th, 2006, 07:35 AM
#2
Re: Populating a comboBox with an ArrayList
Because dbConn.fieldNames returns the ArrayList object as a whole. You need to add
dbConn.fieldNames(a).ToString()
to the combobox.
-
Jul 24th, 2006, 05:43 AM
#3
Thread Starter
New Member
Re: Populating a comboBox with an ArrayList
Hiya, sorry for the delay in replying, hope internet been cut off. Many thanks for your help, works fine now.
Thanks again
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|