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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Kuga
Beginner


Joined: 21 May 2005
Posts: 24

PostPosted: Sun Oct 18, 2009 9:45 pm   

zMUD DB Insert Question
 
I have been attempting to generate an automatic entry of where people or mobs are based upon a where statement. The database was generated in zMUD and sometimes I can get it to insert the values from the command prompt of zMUD but in the trigger (same exact expressions sued) it will not work 100% of the time. I was curious if anyone who had used this extensively could give me some suggestions.

To preface I am parsing through a possible list, if an item exists then I want to add it to the MobLocation table and the columns are MobLoc and DateAdded.

Code:

  #SHOW Attempting DB Addition.
  #DBLOAD MobLocation
  #if (%len( @MobListing.1) <> 0) {
    #SHOW M1 Found
    #NEW MobLocation @MobListing.1 %time
    } {#SHOW FAIL1}
  #IF (%len( @MobListing.2) <> 0) {
    #SHOW M2 Found
    #NEW MobLocation @MobListing.2 %time
    } {#SHOW FAIL2}
  #IF (%len( @MobListing.3) <> 0) {
    #SHOW M3 Found
    #NEW MobLocation @MobListing.3 %time
    } {#SHOW FAIL3}
  #IF (%len( @MobListing.4) <> 0) {
    #SHOW M4 Found
    #NEW MobLocation @MobListing.4 %time
    } {#SHOW FAIL4}
  #IF (%len( @MobListing.5) <> 0) {
    #SHOW M5 Found
    #NEW MobLocation @MobListing.5 %time
    } {#SHOW FAIL5}
  #IF (%len( @MobListing.6) <> 0) {
    #SHOW M6 Found
    #NEW MobLocation @MobListing.6 %time
    } {#SHOW FAIL6}
  #IF (%len( @MobListing.7) <> 0) {
    #SHOW M7 Found
    #NEW MobLocation @MobListing.7 %time
    } {#SHOW FAIL7}
  #DBSAVE


I have tried the following for the #NEW call without success. The above did work from the command line and one run of the trigger, but the second and future times it failed.

Code:
 
#NEW MobLocation {@MobListing.7 %time}
#NEW MobLocation {MobLoc=@MobListing.7 DateAdded=%time}
#NEW MobLocation {MobLoc=@MobListing.7|DateAdded=%time}


Thanks,
Kuga
Reply with quote
Kuga
Beginner


Joined: 21 May 2005
Posts: 24

PostPosted: Mon Oct 19, 2009 10:55 pm   
 
I found a solution using an Access Database and ADO, but still I would like to do this in one line versus what I am doing below for up to eight inserts.

Code:


#if (%len( @MobListing.1) <> 0) {
  #VAR Conn %comcreate( "ADODB.Connection")
  #CALL @Conn.Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\MobLocation.mdb")
  #VAR query
  #VARIABLE query {INSERT INTO MobLoc ( txtLocation ) VALUES ('%replace( @MobListing.1, "'", "")')}
  #CALL @Conn.Execute(@query)
  #CALL @Conn.Close()
  #VAR Conn %null
  #VAR query %null
  } {#SHOW FAIL1}


I noticed when using #CALL @Conn.Dispose() after the close it gives me an error that it cannot be disposed after the connection object is closed. I found that odd as I have done years of VB6 and COM programming for legacy systems where you can close then dispose a connection object. (I realize that Dispose calls close but I found that odd it would cause an error message in zMUD.)

-Kuga
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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