Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Sat Apr 28, 2007 8:37 pm   

External Databases
 
Is there a way to be connected to an external database, and run queries/commands on it from within cmud?
_________________
Rufus- Winner of Stuff
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Apr 28, 2007 11:46 pm   
 
You can use %comcreate and ADOB.Connection object, Try searching this site for %comcreate database.
Have a look at this thread.
Check out the msdn page on using the ADOB.Connection object.
If you're stuck after that post back giving an idea of which database base you want to connect to and maybe an idea of what you want to do with it.
I'm sure we can help you get started.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Tue May 08, 2007 3:55 am   
 
I installed mysql 5
so first I do

#VAR Conn %comcreate( "ADODB.Connection")

then i do

#call @conn.open("test")


which gets this error:

Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

not really sure where to go from here
_________________
Rufus- Winner of Stuff
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: Tue May 08, 2007 7:29 am   
 
You forgot to add a connection string. The connection string is what tells ADO where to find the database, and credentials if it needs any. This page has the various connection strings that you could use:

http://www.connectionstrings.com/?carrier=mysql

ADO also needs a database provider. My experience has been that OleDB providers behave better than ODBC. Your mileage may vary. Go to the MySQL website and look at the Connector downloads. Download and install the ODBC driver if you don't want to mess with .NET stuff. The page for the connectors is here:

http://dev.mysql.com/downloads/connector/
_________________
bortaS
~~ Crusty Klingon Programmer ~~
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Tue May 08, 2007 6:54 pm   
 
Ok, so now I have

#VAR connstr "Driver={MySQL ODBC 3.51 Driver};Server=127.0.0.1;Port=3306;Database=t2t;User=root;Password=nautica;Option=3"
#VAR Conn %comcreate( "ADODB.Connection")
#call %comset(conn,"ActiveConnection",@connStr)
#call @conn.open("test")


.. same error.


Sorry for the constant messages :P Just want to get this right :)
_________________
Rufus- Winner of Stuff
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: Tue May 08, 2007 9:34 pm   
 
No problem. Cool

Try removing "test" from:
#call @conn.open("test")

So that it looks like:
#call @conn.open()

I've never had to use a parameter to open the connection to the database if I provided the info before hand. It's been a while since I've used ADODB. All of my database programming is on .NET nowadays.

After some Googling...

Use ConnectionString property instead of ActiveConnection.
_________________
bortaS
~~ Crusty Klingon Programmer ~~
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: Tue May 08, 2007 9:37 pm   
 
Also don't forget to always close your connection to the database:

#call @conn.Close()

after you get done playing with the database. Open connections to databases do weird things with your code. This is common source for memory leaks.
_________________
bortaS
~~ Crusty Klingon Programmer ~~
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net