Database not found error


Zeal

Recommended Posts

I am inserting data using below sequence. In this sequence Registry.strFileName[0] is my database path and name. The sequence runs fine and my data gets dump good. However after some time there is an error showing unable to connect database. After restarting the sequence manually same error prevails. 

But after restarting Daq Factory project the sequence starts working normally again and data inserting works ok.

while(1)
   if (AutoCycleRunning == 1)
      dbase = db.OpenEx("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Zeal\Hitachi\DB\"+Registry.strFileName[0]+".mdb;Uid=Admin;Pwd=;")
      db.Execute(dbase,"INSERT INTO Data_(A1,A2,A3,A4,A5,A6) values ('"+ FormatDateTime("%Y-%m-%d %H:%M:%S", SysTime()) +"','"+Angle_PV[0]/10+"','"+ Torque[0] +"','"+ DC_Current[0]/100 +"','"+ AC_Current[0]/100 +"','"+ PresentCount[0] +"')")
      db.Close(dbase)
   endif
 

   if (AutoCycleRunning == 0)
      delay(1)
      db.Close(dbase)
      endseq(S3)
   endif
   delay(0.01)
endwhile
   

Link to comment
Share on other sites

I do not recommend opening and closing the database.  Just open it once outside the loop or in an AutoStart sequence and leave it open.  There is no reason to close the connection.  DAQFactory will do this automatically when it quits.

Is the name of this sequence S3?

Link to comment
Share on other sites

I asked because you should replace the endseq(S3) with just return:

  if (AutoCycleRunning == 0)
      delay(1)
      db.Close(dbase)
      return
   endif

 

There is no reason to tell a sequence to stop itself using endseq()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.