How to iterate through database field? Follow

0
Avatar
Todd Sirois

I'm having some confusion on how database fields work.

I have a database connected from an .xls with several columns (fields)

Let's say I have a datasource of:  FIELD: <filename>.Number     (where Number is one of the column names, with some Part Numbers under it eg: "System1")

I want to vbscript to iterate through the results of  FIELD: <filename>.Number so I can test the results against another variable eg; the term "System1"

I have an understanding of how VBScript works but when I try to iterate (For..Each... Next) through  FIELD: <filename>.Number 

   For each n in Field(Number)

   ... do something...

   Next

I get: "Object is not a collection"

If I give the datasource a name "unitnumber" and try:

  For each n in unitnumber

  ... do something...

   Next

I get: "Object doesn't support this property or method."

Is it possible to iterate through the field from a database connection, with vbscript in this manner?

3 comments

0
Avatar
Travis Truax
Comment actions Permalink

Seagull may be the only ones that can answer this definitively. I haven't tried this in BT, but from my experience with other software packages that create their own "internal" DB connections (within the GUI app) and also allow VBscript, often these types of operations aren't possible on the internal DB objects. Again, I'm not confirming that this is the case with BT. Just a thought.

Anyway, you could always just script your own connection entirely as a workaround.

 

0
Avatar
Peter Thane
Comment actions Permalink

Hi Todd,

Not sure if you have found a solution for this or not.

I am not entirely sure what you are trying to achieve but t sounds like you are trying to perform some form of database look up. Couldn't you meet your requirements by using the Filter option in the Database Connection Setup screens?

Pete

0
Avatar
Todd Sirois
Comment actions Permalink

Hi, sorry I never did update.

Yes, I figured out my problem was essentially that I hadn't done a Database Filter yet, I wasn't aware (at the time) how that worked or what to do with it.  Once I figured out how to reach the portions of the database correctly with the filters I was able to work out the code of what I needed.

Pretty much what Peter said is ultimately what I had to do, I just didn't know it yet.  I had made the connections but didn't understand that I had to 'filter' to start getting what I was intending to do.

Please sign in to leave a comment.