I've been messing around so much I don't recall which version of the livecode-server script I sent you. Looking at the one you posted I think I sent the wrong one! <div><br></div><div>The order is wrong, you'll want to declare all the commands and functions FIRST and then actually call them, otherwise they don't yet exist in memory yet and this can cause issues. (at least so it seems to me.</div>
<div><br></div><div>The revised script is here. It doesn't do much, just tries to connect, determines if the open failed, if it did, creates the db and structure instead, then closes itself out. </div><div><br></div><div>
<br></div><div>--declare all handlers first</div><div><div>on DatabaseCreate</div><div>if the gClient of this stack is true then</div><div> put VConnection_Constructor( "localhost", "sa", "sa") into mConn</div>
<div> get VConnection_Open( mConn )</div><div> get ShowError()</div><div> put VDatabase_Constructor( mConn ) into mDatabase</div><div> else</div><div> put VDatabase_Constructor() into mDatabase</div><div> end if</div>
<div> </div><div> get VDatabase_Open( mDatabase, "database1" )</div><div> get ShowError()</div><div> if VDatabase_ErrNumber( mDatabase ) is not "0" then</div><div> if VDatabase_ErrNumber( mDatabase ) is not "532480" then </div>
<div> get VDatabase_Create( mDatabase, "Database1", "kDscDatBlbInd" )</div><div> get showError()</div><div> CreateStructure</div><div> else</div><div> answer VDatabase_ErrString( mDatabase )</div>
<div> close the defaultStack</div><div> end if</div><div> end if</div><div> </div><div> put VDatabase_Table( mDatabase, "Person" ) into mPerson</div><div> put VTable_Field( mPerson, "FirstName" ) into mFirstName</div>
<div> put VTable_Field( mPerson, "LastName" ) into mLastName</div><div> put VTable_Field( mPerson, "BirthDate" ) into mBirthDate</div><div><br></div><div>end DatabaseCreate</div><div><br></div><div>
<br></div><div>on DatabaseClose</div><div> get VDatabase_Close( mDatabase )</div><div> put VDatabase_Destructor( mDatabase ) into mDatabase</div><div>end DatabaseClose</div><div><br></div><div>on CreateStructure</div>
<div> put VDatabase_CreateTable(mDatabase, "Person") into pTable</div><div> </div><div> get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )</div><div> get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )</div>
<div> get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )</div><div>end CreateStructure</div><div><br></div><div>function ShowError</div><div> put Valentina_ErrNumber() into errCode</div><div>
put Valentina_ErrString() into errString</div><div> </div><div> if errCode <> 0 then </div><div> show message box</div><div> put errString into message</div><div> end if</div><div>end ShowError</div><div>
<br></div><div>-- then go through the steps. init, then check for error (using the showError function) </div><div> get valentina_initclient()</div><div> get showError()</div><div><br></div><div>-- call the databasecreate handler</div>
<div> databasecreate</div><div>-- a curiosity check of the current contents of mDatabase && mConn</div><div>-- could do a showError here also</div><div> put mDatabase && mConn</div><div><br></div><div>
-- call the databaseclose handler and shutdown, then put the result of the shutdown. (should be 0)</div><div> databaseClose</div><div> get valentina_shutdown<span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div> put it && the result</div><div>-- I think I mentioned, but I have vserver running in manual mode from the </div><div>--command line so I can watch the connection establish do its thing</div><div>-- and disconnect, live on the console. </div>
<div>?></div></div>