Hi Mike, I am using vb.net 2002.  I looked at the scripting.dictionary class
as suggested earlier in the thread, but I could not understand it.  I would
think a count of the rows would be needed in order to know how many times
the while loop would need to be executed to add the name of each field.

On 13/07/06, Michael Ruck <[EMAIL PROTECTED]> wrote:

If you're using VB6 your choices are VBs native Collection or the
Scripting.Dictionary class mentioned by Craig. Look them up in VBs online
help, there are examples on using them. I'd suggest get more familiar with
VB and its Container classes...

Mike

-----Ursprüngliche Nachricht-----
Von: John Newby [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 13. Juli 2006 18:10
An: sqlite-users@sqlite.org
Betreff: Re: [sqlite] How do you find out the names of the fields within a
table?

Hi Craig, thanks for your comments, but I can't seem to get that to work,
it
says that add and count aren't part of the dictionaryBase or
dictionaryEntry
(those being the only 2 dictionary things i could find in vb)

I think I'm nearly there with the array.

Thanks again for your help

John

On 13/07/06, Craig Morrison <[EMAIL PROTECTED]> wrote:
>
> John Newby wrote:
> > Hi Craig, I have looked into the dictionary that you suggested, but
> > wouldn't this be the same as the array as I would still need to know
> > how many
> times
> > to go through the while loop to add the names of the fields?  Also I
> > need to get the names of the fields back out to populate a comboBox,
> > which I already know how to do with an array.
>
> item = myDict("hash")
>
> Its pretty simple.
>
> Use your favorite search engine to look for "scripting.dictionary" and
> you will find a wealth of information on VBScript's dictionary object.
>
> From an earlier message of yours:
>
> >        ' 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()
> >        i = 0
> >        While sqlite_datareader.Read()
> >            'Try
> >            fieldNames(i) = sqlite_datareader("name")
> >            'atch es As Exception
> >            '  MessageBox.Show(es.Message)
> >            End Try
> >            i += 1
> >        End While
> >
> >        sqlite_datareader.Close()
>
> You are already getting the field names on the fly, why do you insist on
>   knowing how many fields there are?
>
> After you populate the dictionary, you can get the count of items
> (fields) by doing:
>
> itemCount = myDict.Count
>
> To attempt to stave off any more questions:
>
> set fieldNames = CreateObject("Scripting.Dictionary")
> sqlite_cmd.CommandText = (strSQL)
> sqlite_datareader = sqlite_cmd.ExecuteReader() i = 0 While
> sqlite_datareader.Read()
>      fieldNames.Add i, sqlite_datareader("name")
>      i += 1
> End While
> sqlite_datareader.Close()
> fieldCount = fieldNames.Count
>
> Your problem is *not* sqlite, but rather a command of VB itself. You
> might want to spend some time getting up to speed on VB.
>
> Or better yet, why don't you just pass a reference to the list box and
> add them directly to it?
>
> I'm not going to comment further on this topic as it is now QUITE far
> off-topic.
>
> --
> Craig Morrison
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> http://pse.2cah.com
>    Controlling pseudoephedrine purchases.
>
> http://www.mtsprofessional.com/
>    A Win32 email server that works for You.
>


Reply via email to