C
Cameron
We have an access database that draws environmental data from the various
pieces of equipment that manages volitiles burning. This data in turn gets
submitted as a report to the evnironmental control agencies. Everytime the
Enviro guy opens the database he gets the error 3151 saying it could not find
the SQL database. The database is running an event update query with the
following code when it starts. I tried building a DSN for this connection but
it did not seem to help. What might I be missing with respect to how this
function connects to this SQL database?
Function getEvents(txt As String) As Recordset
On Error GoTo errhandle
Dim db As Database
Dim qdef As QueryDef
Dim TheServer As String
Static IpData As Recordset
Dim errmsg As String
' This function takes an sql text string and executes it against the
ip21 database'
' The string "txt" should be able to execute in sql plus
' using sql plus in this way, you can trouble shoot the sql text string
Set db = DBEngine.Workspaces(0).Databases(0)
'create a temporary query def
Set qdef = db.CreateQueryDef("")
With qdef
TheServer = "EdsonIP21"
.Connect = "ODBC;DATABASE=pubs;=;PWD=;DSN=" & TheServer
.SQL = txt
Set IpData = .OpenRecordset(, dbOpenDynaset)
End With
Set getEvents = IpData
'close everything nicely
'db.Close
' the qdef has a null name and is "temporary" so _
it doesn't need to be deleted or closed
If ((IpData.EOF And IpData.BOF) And IpData.RecordCount = 0) Then
'UpdateDialog , 0, "no events found in IP21"
NoRecords = True
Exit Function
End If
UpdateDialog , IpData.RecordCount
Exit Function
pieces of equipment that manages volitiles burning. This data in turn gets
submitted as a report to the evnironmental control agencies. Everytime the
Enviro guy opens the database he gets the error 3151 saying it could not find
the SQL database. The database is running an event update query with the
following code when it starts. I tried building a DSN for this connection but
it did not seem to help. What might I be missing with respect to how this
function connects to this SQL database?
Function getEvents(txt As String) As Recordset
On Error GoTo errhandle
Dim db As Database
Dim qdef As QueryDef
Dim TheServer As String
Static IpData As Recordset
Dim errmsg As String
' This function takes an sql text string and executes it against the
ip21 database'
' The string "txt" should be able to execute in sql plus
' using sql plus in this way, you can trouble shoot the sql text string
Set db = DBEngine.Workspaces(0).Databases(0)
'create a temporary query def
Set qdef = db.CreateQueryDef("")
With qdef
TheServer = "EdsonIP21"
.Connect = "ODBC;DATABASE=pubs;=;PWD=;DSN=" & TheServer
.SQL = txt
Set IpData = .OpenRecordset(, dbOpenDynaset)
End With
Set getEvents = IpData
'close everything nicely
'db.Close
' the qdef has a null name and is "temporary" so _
it doesn't need to be deleted or closed
If ((IpData.EOF And IpData.BOF) And IpData.RecordCount = 0) Then
'UpdateDialog , 0, "no events found in IP21"
NoRecords = True
Exit Function
End If
UpdateDialog , IpData.RecordCount
Exit Function