DaiDreamer
Programmer
I'm having a database problem now. I get a error message everytime my program opens up the database. Can anyone help?
here's the error message:
Line: 37 Char: 3
Error: Data source name not found and no default driver specified.
here's the code:
Option Explicit
' Database Variables
Dim objConn, ObjRS, strQuery
Dim strConnection
Dim strAddress, StrSubject
' Mail Variables
Dim cdoSession, inbox, messages, message, msgID, i, objMessage, objMessages, objFolder, objSession, objMessageFilter
Const adUseServer = 2
Const adOpenKeyset = 1
Const adCmdTable = 2
Const adLockOptimistic = 3
Set objSession = CreateObject("MAPI.Session"
objSession.logon
Set objFolder = objSession.Inbox
Set objMessages = objFolder.Messages
Set objMessageFilter= objMessages.Filter
'objMessageFilter.Or= True
'objMessageFilter.Subject="Remove"
'objMessageFilter.Subject="Registration"
Set objMessage=objMessages.GetFirst
If objMessage Is Nothing Then
MsgBox "Folder is Empty"
else
'loop through other messages
Do While Not objMessage Is Nothing
strAddress= objMessage.Sender
strSubject = objMessage.Subject
Set objConn = CreateObject("ADODB.Connection"
strConnection= "DSN=POCKETMOSAIC"
objConn.Open strConnection 'line 37
strQuery= "SELECT PagerAddress FROM Users "
strQuery= strQuery & "ORDER BY PagerAddress"
Set objRS = objConn.Execute ( strQuery )
'if the pager address needs to be removed from the db
if strSubject = "Remove" then
MsgBox "remove"
While not(objRS.EOF)
if objRS("PagerNumber" = strAddress Then
objRS.Delete
MsgBox strAddress
end if
wend
'if the pager address need to be added to the db
ElseIf StrSubject = "Registration" then
MsgBox "Add"
objRS.AddNew
objRS("PagerNumber"=strAddress
objRS.Update
MsgBox strAddress
End if
Set objMessage= objMessages.GetNext
Loop
End if
objRS.close
objConn.close
Set objMessage = nothing
Set objMessages = nothing
Set objFolder= nothing
Set objSession = nothing
Set objRS = nothing
set objConn= nothing
MsgBox "Done!"
cdoSession.Logoff
here's the error message:
Line: 37 Char: 3
Error: Data source name not found and no default driver specified.
here's the code:
Option Explicit
' Database Variables
Dim objConn, ObjRS, strQuery
Dim strConnection
Dim strAddress, StrSubject
' Mail Variables
Dim cdoSession, inbox, messages, message, msgID, i, objMessage, objMessages, objFolder, objSession, objMessageFilter
Const adUseServer = 2
Const adOpenKeyset = 1
Const adCmdTable = 2
Const adLockOptimistic = 3
Set objSession = CreateObject("MAPI.Session"
objSession.logon
Set objFolder = objSession.Inbox
Set objMessages = objFolder.Messages
Set objMessageFilter= objMessages.Filter
'objMessageFilter.Or= True
'objMessageFilter.Subject="Remove"
'objMessageFilter.Subject="Registration"
Set objMessage=objMessages.GetFirst
If objMessage Is Nothing Then
MsgBox "Folder is Empty"
else
'loop through other messages
Do While Not objMessage Is Nothing
strAddress= objMessage.Sender
strSubject = objMessage.Subject
Set objConn = CreateObject("ADODB.Connection"
strConnection= "DSN=POCKETMOSAIC"
objConn.Open strConnection 'line 37
strQuery= "SELECT PagerAddress FROM Users "
strQuery= strQuery & "ORDER BY PagerAddress"
Set objRS = objConn.Execute ( strQuery )
'if the pager address needs to be removed from the db
if strSubject = "Remove" then
MsgBox "remove"
While not(objRS.EOF)
if objRS("PagerNumber" = strAddress Then
objRS.Delete
MsgBox strAddress
end if
wend
'if the pager address need to be added to the db
ElseIf StrSubject = "Registration" then
MsgBox "Add"
objRS.AddNew
objRS("PagerNumber"=strAddress
objRS.Update
MsgBox strAddress
End if
Set objMessage= objMessages.GetNext
Loop
End if
objRS.close
objConn.close
Set objMessage = nothing
Set objMessages = nothing
Set objFolder= nothing
Set objSession = nothing
Set objRS = nothing
set objConn= nothing
MsgBox "Done!"
cdoSession.Logoff