Jump to content
  • Advertisement
Sign in to follow this  
tfinck

Converting local to SQL

This topic is 2647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there, so basically I'm working on converting a game server (written in VB6), that saves account information locally, to one that saves in through MySQL. I'd prefer not having to do this (as it seems like a lot of work), but if so, is there an efficient way to do this? Am I better off just leaving the server file as is? Here's the source for the game server




Sub LoadPlayer(ByVal index As Long, ByVal Name As String)
Dim filename As String
Dim F As Long
Call ClearPlayer(index)
filename = App.Path & "\data\accounts\" & Trim(Name) & ".bin"
F = FreeFile
Open filename For Binary As #F
Get #F, , Player(index)
Close #F
End Sub



Any and all help/criticism/advice is welcome!

Share this post


Link to post
Share on other sites
Advertisement
What reasons do you have for wanting to use a relational DB for storing your server data? Also, you'd probably get a lot more help if you isolated the pieces of code that actually do the reading/writing of the server data, and limit those to the data you want stored. Otherwise no one is going to sift through hundreds of lines of VB code to find the relevant portions.

Share this post


Link to post
Share on other sites
Sorry about the code, all the functions are relevant, ban lists, adding players, removing players. I'll just isolate the section I would say is most important. I assume saving account information to a database, rather than a simple text file, is much safer.

This is how the current source saves account information
Click here for image


I just want some better protection. I understand that I'd have to connect to the database in question


Private Sub cmdConnectMySQL_Click()

Dim cnMySql As New rdoConnection
Dim rdoQry As New rdoQuery
Dim rdoRS As rdoResultset

cnMySql.CursorDriver = rdUseOdbc
cnMySql.Connect = "uid=YourUserName;pwd=YourPassword;
server=YourServerName;" & _
"driver={MySQL ODBC 3.51 Driver};
database=YourDataBase;dsn=;"
cnMySql.EstablishConnection

With rdoQry
.Name = "selectUsers"
.SQL = "select * from user"
.RowsetSize = 1
Set .ActiveConnection = cnMySql
Set rdoRS = .OpenResultset(
rdOpenKeyset, rdConcurRowVer)
End With

' loop through the record set
' processing the records and fields.

Do Until rdoRS.EOF
With rdoRS

' your code to process the fields

rdoRS.MoveNext
End With
Loop

' close record set
' close connection to the database

rdoRS.Close
cnMySql.Close

End Sub



But what else needs to go into it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!