• Welcome to Valhalla Legends Archive.
 

Database Problems

Started by LizArD, March 03, 2004, 02:29 PM

Previous topic - Next topic

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

K

#1
Ok, so I'm anal.


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

LizArD

thx for organizing it lol now lets just see if we can fix it =\

Eric

#3
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.

LizArD

I didn't code this bot, Yell at Voodoo

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
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

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 =)