Valhalla Legends Forums Archive | Battle.net Bot Development | Database Problems

AuthorMessageTime
LizArD
I did not make this source, it was given to me by Voodoo[Fa], this is just the database part of it. He wont help me so I turn to these forums :) Anyway, when I add someone with any flag it seems to add fine of course, then when I reload the bot, it says "Error in database" I don't know what information you need to help me, so I just pasted the whole source for database.. Any help be great =]

Public Sub LoadDB()
On Error Resume Next
Dim Change As Boolean
Dim Splt() As String
Dim Tempa As al
'username, rank, flags, date, time, addedby
Open "Database.txt" For Input As #1
Do Until EOF(1)
Line Input #1, Item
If Item <> "" Then
Splt() = Split(Item, " ")
If UBound(Splt) > 3 Or UBound(Splt) < 3 Then
MsgBox "Error loading database", vbCritical, "Error"
End
End If
If Splt(1) >= 101 Or Splt(1) < 0 Then
MsgBox "Error loading database", vbCritical, "Error"
End
End If
If UCase(Splt(2)) <> "NO" And UCase(Splt(2)) <> "S" And UCase(Splt(2)) <> "B" And UCase(Splt(2)) <> "K" Then
MsgBox "Error loading database", vbCritical, "Error"
End
End If
If Splt(1) > 0 And UCase(Splt(2)) <> "NO" Then
MsgBox "Error loading database", vbCritical, "Error"
End
End If
If UCase(Splt(6)) <> "NONE" Then
Tempa.BMessage = Splt(3)
Else
Tempa.BMessage = "None"
End If
Tempa.Rank = Splt(1)
Tempa.Flags = UCase(Splt(2))
Tempa.Username = Splt(0)
AddAccess Tempa
End If
Ending69:
Loop
Close #1
SaveAccessList
End Sub
March 3, 2004, 8:29 PM
K
Ok, so I'm anal.

[code]
Public Sub LoadDB()
On Error Resume Next

Dim Change As Boolean
Dim Splt() As String
Dim Tempa As al

'username, rank, flags, date, time, addedby
Open "Database.txt" For Input As #1
   
Do Until EOF(1)



      Line Input #1, Item

      If Item <> "" Then
         Splt() = Split(Item, " ")

         If UBound(Splt) > 3 Or UBound(Splt) < 3 Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If Splt(1) >= 101 Or Splt(1) < 0 Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If UCase(Splt(2)) <> "NO" And UCase(Splt(2)) <> "S" _
And UCase(Splt(2)) <> "B" And UCase(Splt(2)) <> "K" Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If Splt(1) > 0 And UCase(Splt(2)) <> "NO" Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If UCase(Splt(6)) <> "NONE" Then
            Tempa.BMessage = Splt(3)
         Else
            Tempa.BMessage = "None"
         End If

         Tempa.Rank = Splt(1)
         Tempa.Flags = UCase(Splt(2))
         Tempa.Username = Splt(0)
         AddAccess Tempa

      End If
Loop

Close #1

SaveAccessList

End Sub
[/code]
March 3, 2004, 8:35 PM
LizArD
thx for organizing it lol now lets just see if we can fix it =\
March 3, 2004, 8:53 PM
LoRd
Would help to not copy directly from my open source Shadow Bot project, and when you do, copy everything you need, not just half of what you need.

You need to learn how to use dynamic arrays.
http://pscode.com/vb/

This post should be in the Visual Basic forum, not this one.

EDIT: Ew, when looking at my coding, keep in mind Shadow Bot was coded over a year and a half ago.
March 3, 2004, 8:57 PM
LizArD
I didn't code this bot, Yell at Voodoo
March 3, 2004, 9:09 PM
Kp
Without reading your code in any detail, I can say that the problem is that your LoadDB and SaveDB routines disagree on the format in which data is saved. As a result, LoadDB gives an error when it receives an improperly formatted database. Fix your SaveDB code. :P
March 4, 2004, 12:01 AM
LizArD
Thanks a lot, lol it actually was the save. It was reading spaces in between the seperators, and I had boxes. All fixxed now =)
March 4, 2004, 12:48 AM

Search