Connecting to SQL Server Via Access

shamas21

Registered User.
Local time
Today, 20:37
Joined
May 27, 2008
Messages
162
Hi All

I have the following code that tried to connect to SQL Server via Access but doesnt work as it returns the following error "Error HRESULT E_FAIL has been returned from a call to a COM component."

Code:
        Dim oAccess = New Access.ApplicationClass()


        Dim sDBPath As String = "\\DELLCVSERVER\RedirectedFolders\shamal.samal\Desktop\AssignLeads\test2.adp"

        oAccess.OpenAccessProject(sDBPath)

        MsgBox(oAccess.CurrentProject.Name)

        oAccess.Application.CurrentProject.OpenConnection("Data Source=DELLCVSERVER\CAPITALVISAS;Initial Catalog=CapitalVisasCRM;Integrated Security=True")

        oAccess.DoCmd.RunSavedImportExport("Import-test111")

        oAccess.CurrentProject.CloseConnection()

        oAccess = Nothing

Can someone tell me what im doing wrong?

Thanks
 

Users who are viewing this thread

Back
Top Bottom