Access Database speed problem?

Hildegaard
10-18-2004, 12:12 PM
Hello there...

I have a problem when loading character information from a msAccess database for the MUD server im coding.

The problem is not a problem with the database itself, but with the speed on the loading data sub. This means that, when i try to log X character for the 1st time, the server will get stucked in some part and not send the 'log in' information to the client. But if i close the client and try again, since the array is already with the client's data, it works perfectly.... this happens with every new character i want to log on the server...




This is part of the 'incomming data' sub that decrypts everything from the string gotten from client. (GetUserInfo returns X data from Y name)

If Split(data, "`")(0) = "login" Then
Dim Password As String
Dim Password2 As String
Name = Split(data, "`")(1)
Password = Split(data, "`")(2)
If client(Socket).Vrfy = False Then ' Veryfication Incorrect
'Ban_Ip socket
Logout_Client Socket
Exit Sub
End If
Password2 = GetUserInfo(Name, "Password")
If Password <> Password2 Then ' Password Incorrect
SendData Socket, "deny`Wrong Password!`"
Logout_Client Socket
Exit Sub
End If
client(Socket).Name = Name: DoEvents

LoadClient (Socket) ' Loads all the character information from DB to Array

AddCharToRoom client(Socket).Location, Socket
DoEvents
SendCritInfo Socket ' Sends character information (stats, name, div, etc)
DoEvents
SendRoomInfo Socket ' Sends the client, the room information
DoEvents
End If




Sub AddCharToRoom(Location As String, Socket As Integer)
' Adds a new socket number to the list of Active players in the room list
Room(client(Socket).Location).PlayerList = Room(client(Socket).Location).PlayerList & Socket & "`"
End Sub

Public Sub LoadClient(Socket As Integer)
Dim Number As Variant
Dim ClientDB As DAO.Database
Dim ClientRS As DAO.Recordset
Set ClientDB = OpenDatabase(App.Path & "\users.mdb")
Dim StrSQL As String
Dim InfoToReturn

StrSQL = "SELECT * FROM Crits " & "WHERE Name='" & client(Socket).Name & "'"
Set ClientRS = ClientDB.OpenRecordset(StrSQL)

client(Socket).Password = ClientRS!Password
client(Socket).Class = ClientRS!BaseClass
client(Socket).ShowClass = ClientRS!ShowClass
client(Socket).Level = ClientRS!Level
client(Socket).Exp = ClientRS!Exp
client(Socket).Armor = ClientRS!Armor
client(Socket).Hp = ClientRS!Hp
client(Socket).HpMax = ClientRS!HpMax
client(Socket).Mp = ClientRS!Mp
client(Socket).MpMax = ClientRS!MpMax
client(Socket).Gold = ClientRS!Gold
client(Socket).Attacks = ClientRS!Attacks
client(Socket).Location = ClientRS!Location
client(Socket).Str = Split(ClientRS!Stats, "`")(0)
client(Socket).Int = Split(ClientRS!Stats, "`")(1)
client(Socket).Agi = Split(ClientRS!Stats, "`")(2)
client(Socket).End = Split(ClientRS!Stats, "`")(3)
client(Socket).Wis = Split(ClientRS!Stats, "`")(4)
client(Socket).Chr = Split(ClientRS!Stats, "`")(5)
client(Socket).Sex = ClientRS!Sex
client(Socket).Div = ClientRS!Div
client(Socket).Picture = ClientRS!Pic
client(Socket).Race = ClientRS!Race
End Sub

Private Sub SendCritInfo(Socket As Integer)
'Sends character information (stats, name, div, etc)
'Used for login information.
SendData Socket, "fdisplayupdate`" & client(Socket).Name & "`" & client(Socket).Password _
& "`" & client(Socket).Level & "`" & client(Socket).Armor & "`" & client(Socket).Str _
& "`" & client(Socket).Int & "`" & client(Socket).Agi & "`" & client(Socket).End _
& "`" & client(Socket).Wis & "`" & client(Socket).Chr & "`" & client(Socket).Mp & "`" _
& client(Socket).Class & "`" & client(Socket).ShowClass & "`" _
& client(Socket).Race & "`" & client(Socket).Sex & "`" & client(Socket).Div & "`" _
& client(Socket).Gold & "`" & client(Socket).Exp & "`Monthly`" & client(Socket).Picture & "``nc``" & Chr(10) & _
"statupdate`hits`" & client(Socket).Hp & "/" & client(Socket).HpMax & "`" _
& client(Socket).Hp & "`" & client(Socket).HpMax & "`Ready``" & Chr(10) & _
"statupdate`attack`" & client(Socket).Attacks & "`" & client(Socket).Attacks & "``" & Chr(10) & _
"statupdate`level`" & client(Socket).Level & "`" & Chr(10)
End Sub

Sub SendRoomInfo(Socket As Integer)
'Sends Information about the ROOM the client is on.
'This is used for when a client walks in a room
'or when a client logs on.
'
' * Sends : short decription of the room, userlist, monsterlist, itemlist,
' room picture, etc.

'move`Temple of Fire`000006`You are in the Temple of Fire. The exit to the south leads back to Commerce Circle.``DefaultMenu`4385`C@4364@`K```
Dim SndDec As String
Dim ClientList As String
Dim Loc As Integer
Dim NumSocks As Integer
Dim SockList As String
Dim TempSock As Integer
Loc = client(Socket).Location
NumSocks = NumTok(Room(Loc).PlayerList, "`")
SockList = Room(Loc).PlayerList
ClientList = "ListUpdate`" & NumSocks & "`Output`End`"

For I = 0 To NumSocks - 1
TempSock = Split(SockList, "`")(I)
ClientList = ClientList & client(TempSock).Name & "`" & client(TempSock).Picture & "`1`" & I & "`"
Next I

SndDec = "move`" & Room(Loc).Name & "`" & Room(Loc).Picture & "`" & Room(Loc).sDesc & "``" _
& Room(Loc).Menu & "`" & Loc & "`````" & Chr(10) & Room(Loc).Menu & "`" & Chr(10)

SendData Socket, SndDec & ClientList
End Sub


thats pretty much it what is causing me trouble... maybe the problem is that im putting everything in different subs when i could just do it all together???

can someone tell me where is the point that VB gets stucked or lose the order of things.


Thanks a lot :)
Bruno

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum