Object Library problem
Thank You for Your answer.
Now I'm using code like this, and it's working:
Sub DoMail(MailAddress As String)
Dim AppMail As Object
Set AppMail = CreateObject("OutLook.Application")
With AppMail.CreateItem(olMailItem)
.To = MailAddress
.Subject = "Work is ready"
.Body = "Check the worksheet for results."
.Send
End With
Set AppMail = Nothing
End Sub
Is this same kind of technique possible when using ADO connection to SQL
Server? Here is a sample code that I'm currently using (which requires me to
select Microsoft ActiveX Data Objects Library in advance (Tools /
References)):
Public cnADO As ADODB.Connection
Public Rs1 As ADODB.Recordset
Public strConn As String
Sub DoConnection()
Set cnADO = New ADODB.Connection
strConn = "provider=sqloledb;" & _
"data source=xxx;" & _
"initial catalog=xxx;" & _
"user id=xxx;" & _
"password=xxx;"
cnADO.Open strConn
End Sub
Sub Main_program()
DoConnection
Set Rs1 = New ADODB.Recordset
Rs1.ActiveConnection = cnADO
Rs1.Open "SELECT * FROM ..."
...
End Sub
|