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
Chuft
Newbie


Joined: 10 Sep 2009
Posts: 5
Location: England

PostPosted: Sun May 22, 2011 12:31 pm   

[3.34] Access sql queries with ado com objects
 
I bought cmud yesterday and I have been trying ever since to make th simplest of ado sql queries run without causing a crash of the entire client, but have had limited success..even when data is retreived cmud still crashes. I know it supports sqllite db sql queries directly but I have no wish totranslate all my databases and break my zmud before my cmud works at all.
I added an onconnect method to clear com objects thus:
Code:

#FORALL @conntab {
comRef = %db( %i, Object)
#IF (%bitand( %db( %i, Flags), %db( @comflags, isTest))) {comRef = %db( %i, TestObject)}
#VAR @comRef ""
#CALL %vartype( @comRef, 8)
}
;;
#ECHO %cr
;;
#ECHO <color orange>onConnect: </color><color white>COM Objects released</color>
;;
#ECHO %cr

and the sql query itself, which takes 2 arguments, zoneabbreviation and mobabbreviation, and queries against an access db to return a map vnum location and walk there, is as follows:
Code:

#VAR rs %null
#VAR rs %comcreate( "ADODB.Recordset")
#VAR ConnStr "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\zmud\aardwolf\db\mobbiewalks.mdb"
#var tempmobname %1
#var tempareaname %2
#VAR Sql %concat("SELECT * FROM moblist WHERE areaKey = '",%1,"' AND mobKey = '",%2"'")
#CALL @rs.Open( @Sql, @ConnStr)
#say @Sql
#IF (not @rs.eof) {
  #VAR Fields @rs.Fields
  #ECHO @Fields("speedwalk").Value
  #ECHO @Fields("mobFullname").Value
  #VAR mobfastwalk @Fields.Item("speedwalk").Value
  #VAR Empty 0
  #VAR Fields %null
  } {#VAR Empty 1}
#CALL @rs.Close
#VAR Conn %null
#if (@Empty > 0) {#say Record not found} {#EXEC @mobfastwalk}
#VAR rs %null

Once I figured out the inline expansion change within quotes this behaves as expected and queries correctly but the entire client promptly crashes at some point during this and has to be killed in task manager and reopened. Zmud has handled similar code flawlessly for years, so how would I fix this? if I can't get my queries to my sundry backend sql databases working I will not be keen on using cmuyd, as my mobdb has upwards of 6k records for example, and other scripts rely on smooth access to external com resources such as this and java displays.
in zmud(run offline), if I then execute the command "mw oz crow", I get the output:
Code:

//printed inside function
go 6225
a crow
//called to the "go mapvnum" method which is not relevant here:
get timegold portals
hold timegold
enter
hold 'tiger kai'
put timegold portals
The Beach
  You see a beautiful tropical beach.  Exotic birds sing in melody.  To the
east is a small shack with a faded sign.  To the west is a hut made of logs
and sticks.  North lies what looks like a stone age village.  You scuffle
the sand and see a depression. 

Exits: s, d, w, e, n
>

run s2en3e
oz
run 2ne3ne2n3e
Not in Kansas!

  You don't know where you are, but you don't think you're in
Kansas anymore.  To the north, you see an odd little garden with small
people dancing in it.  Since, once again, you can't go back the way you
came, you decide to press on northward. 

[Exits: north]
Exits: n
>


the same stuff for cmud gives the same output including attempting to execute the "go 6225" command, but then always crashes, throwing a prse error "Access violation at address 00d4cde2 in module "cmud.exe." read of address 00000000.

other sql scripts I have attempted to modify in the day since purchasing cmud have almost unfailingly done something similar even if the zscript syntax remains (relatively) unchanged.
there doesn't appear to be much posted about issues with ado sql in cmud and the fact that it crashes rather than giving helpful error messages has become very frustrating.
Does anyone have any experience or suggestions for this functionality in cmud?
Thanks
Reply with quote
Chuft
Newbie


Joined: 10 Sep 2009
Posts: 5
Location: England

PostPosted: Sun May 22, 2011 2:48 pm   
 
I replicated this behaviour with the same code in a clean session of a restarted cmud that contained only this alias.
Reply with quote
Chuft
Newbie


Joined: 10 Sep 2009
Posts: 5
Location: England

PostPosted: Sun May 22, 2011 8:14 pm   
 
Code:

#VAR rs %null
#VAR Sql %concat("SELECT * FROM moblist WHERE areaKey = '",%1,"' AND mobKey = '",%2"'")
#SQLDB mobwalk c:\cmud\aardwolf\db\mobbiewalkstest.db3
rs = %sql(mobwalk, @Sql);
#say @Sql
#WHILE (!@rs.Eof()) {#SHOW @rs.Item("speedwalk")
#SHOW @rs.Item("mobFullname")
#CALL @rs.Next}
#SQLCLOSE mobwalk
#VAR Conn %null
#VAR rs %null

is generating the same error on an sqllite version of the same database accessed by the previous code, and I am still using the above method to clear com objects.
once again I am running this code from a clean session. No ado code is involved, except however zmud's sql* methods work, not sure what else to try :)
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