I have a MS SQL Server database that is being used as the backend for an MS Access ADP file. I used the File, Connection to specify the server information. For most of the Forms I have used stored procedures and called them with VB using code similar to the code below:
Dim cnn As Connection
Set cnn = CurrentProject.Connection
Dim rstWipJob As Recordset
Dim rstPrmWIPJ As ADODB.Parameter
Set rstComWIPJ = New ADODB.Command
rstComWIPJ.ActiveConnection = cnn
.ActiveConnection = CurrentProject.Connection
.CommandText = "JobNumLookup"
.CommandType = adCmdStoredProc
Set rstPrmWIPJ = .CreateParameter("@WipJobNum", _
adVarChar, adParamInput, 30)
rstPrmWIPJ = Me![WIPJobNum]
Set rstWipJob = rstComWIPJ.Execute
This seems to work perfectly as it executes the Stored Procedure and passes the variable exactly as I expected it to. If I am making any errors or there is a better way too do this please let me know... There are a few Forms that someone else defined that take data (and it is verified) but simply use the DoCmd .Close command to save the data rather than actually executing an SQL command or SP. I don't know if allowing these forms to use the DoCmd.Close method of saving is a problem or not?
My main problem is that some of the clients use wireless to access the application. For the most part this works perfectly fine but occaisionally the database goes to a "Disconnected" state. I believe this typically happens if the user doesn't use the application for a long time (power settings relating to battery life may cause it to standby or hibernate.) What is the best way (even if it means changing the way I am creating connections etc. in my code) to reconnect the database when it goes into this offline state?
Some of the buttons open forms using Stored Procedures (to filter down to a specific record) and some use the Do.Cmd saving method instead of an actual Insert or Update statement sent via a connection and recordset object.
Can anyone offer some help? Is using the syntax above acceptable?