|
Belmyrddyn Magician
Joined: 17 Oct 2001 Posts: 371 Location: USA
|
Posted: Tue Mar 04, 2003 12:00 am
ADO Database Loop |
Okay, this bit of script is designed to retrieve all of the 'Friends' (stored in an ADO database) that the character I'm connected to has stored. It saves it into 10 different string lists, depending on what color I want the Friend's name to be highlighted. @Friends1 - @Friends10.
Now, for the most part this script works, however the first item of each stringlist is the name of the stringlist itself, which I'm at a total loss to understand why. Second, it only loads 1 name from each color code, no matter how many entries are in the database.
#VAR SQL %concat( %char( 34), "SELECT * FROM [tblFriends] WHERE [Name] = ~'", %item( @Character, 1), "~' ORDER BY [Color Code]", %char( 34))
#CALL @DBConnection.Open( @SQL, @ConnStr, 2, 2)
#IF ((@DBConnection.bof) AND (@DBConnection.eof)) {#CALL @DBConnection.Close} {
#CALL @DBConnection.MoveFirst
#LOOP 10 {
#IF (@DBConnection.eof) {#ABORT}
#VAR Temp %i
#WHILE (%int( @DBConnection( "Color Code")) = %i) {
#IF (@DBConnection.eof) {#ABORT}
#VAR %concat( "Friends", @Temp) %additem( @DBConnection( "First Name"), %concat( "Friends", @Temp))
#CALL @DBConnection.MoveNext
}
}
}
#CALL @DBConnection.Close
The SQL statement works, so you don't need to check that.
Belmyrddyn |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Mar 04, 2003 3:15 am |
The problem is in the %additem. Instead of saving the counter to a temporary variable, use the %i directly, like this:
#VAR Friends%i %additem(@DBConnection("First Name), @{Friends%i})
Kjata |
|
|
|
Belmyrddyn Magician
Joined: 17 Oct 2001 Posts: 371 Location: USA
|
Posted: Tue Mar 04, 2003 3:33 am |
Can you do that in a sub-loop structure? I assumed %i would be taken over by the #WHILE structure, but I want the %i of the #LOOP structure.
EDIT: Okay, just implemented it, and it works like a CHARM. Thanks so much, Kjata, I had spent forever banging my head with this one.
Belmyrddyn |
|
|
|
Belmyrddyn Magician
Joined: 17 Oct 2001 Posts: 371 Location: USA
|
Posted: Tue Mar 04, 2003 4:17 am |
In conjunction with this... is there a variable which has the number of times the #WHILE structure had repeated?
Belmyrddyn |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Mar 04, 2003 5:05 am |
Nope, you need to maintain your own counter for that.
Kjata |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|