Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Game Programming - Data Bases

Status
Not open for further replies.

xTiamatx

Programmer
Jul 20, 2003
22
0
0
US
Hey.. this is a very general question because I don't know a lot about the area, I'm programming a game, and I need to have the server save a bunch of information. I need a fast and efficient way of doing this. The way I am doing it right now is, everytime a player leaves the game, it creates a .txt file for that player, so I will end up with tens of thousands of .txt files, I'd like to do it in microsoft access or something similar, or just one huge .txt file

If anyone could help me, that'd be great, thanks

-Kerry
 
use DAO to access and update MS Access databases.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
what is DAO? and where would I learn to implement it into C++??? I'm just getting into this and have no idea how to do it at all
 
This is a short sample:
#include <stdio.h>
#include <afxdisp.h>

#import &quot;c:\program files\common files\system\ado\msado15.dll&quot; rename (&quot;EOF&quot;,&quot;adoEOF&quot;) no_namespace

#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); if (FAILED(_hr)) _com_issue_error(_hr); }

#define RsITEM(rs,x) rs->Fields->Item[_variant_t(x)]->Value
#define UC (char *)
struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_; // Global Instance to force load/unload of OLE

void main(){

_RecordsetPtr spRS;
_ConnectionPtr spCON;
try{
CREATEiNSTANCE(spCON,Connection);
spCON->ConnectionString = L&quot;driver={sql server};SERVER=(local);Database=pubs;&quot;
L&quot;UID=sa; PWD=;&quot;;
spCON->ConnectionString =L&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
L&quot;DBQ=authors.MDB;DefaultDir=C:\\test;&quot;;

spCON->Open( &quot;&quot;, &quot;&quot;, &quot;&quot;, -1 );
CREATEiNSTANCE(spRS,Recordset)
spRS->PutRefActiveConnection( spCON );
spRS->Open(&quot;select au_lname, au_fname from authors&quot;, vtMissing, adOpenKeyset,
adLockBatchOptimistic, -1);

while(spRS->adoEOF == false){
printf(&quot;au_lname = %s au_fname = %s \n&quot;, UC _bstr_t(RsITEM(spRS,0L)),
UC _bstr_t(RsITEM(spRS,&quot;au_fname&quot;)));
spRS->MoveNext();
}
spRS->Close();
spCON->Close();

}
catch( _com_error &e){
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(&quot; Error: &quot;) + _bstr_t(e.Error()) + _bstr_t(&quot; Msg: &quot;)
+ _bstr_t(e.ErrorMessage()) + _bstr_t(&quot; Description: &quot;)
+ _bstr_t(e.Description());

MessageBox(0,bs,bstrSource, MB_OK);
}
}
#undef UC

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Okay cool, that helps a lot, trying to implement now :)

Thanks,
Kerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top