Jumat, 11 Agustus 2017

[MS_AccessPros] Re: Passing a string from an API

 

Hi Art

I've never used that reference before, but check to see if it has a "Connect" or ConnectString property. If you open the connection and then open a watchwindow on the connection. You will be able to drill down to see all the properties.

But if what you want is the connection itself, you can't close it once it is open. And you will have to pass the connection as a reference. I've passed connections like this. A lot of the code is useless to you because I have other internal routines in play, but you can see how I pass the connection as an ADODB.Connection

'Routine:
Public Function RunProcImpTbl(strSP As String, cnn As ADODB.Connection) As Boolean
'Purpose  : Run Import Job to fill import table(s).
'DateTime : 9/13/2005 15:01
'Author   : Bill Mosca
'Jobs     :
'   File_Import_AcctDat (includes AcctDat and AcctDesc)
'   File_Import_CC_CCGrps
'   File_Import_IPDescr_ProdVol
'   File_Import_JobCodes
'   File_Import_LMFiles
'   File_Import_Opns
'   File_Import_PC1
    Dim strStoredProc As String
    Dim cmd As ADODB.Command
    Dim strJob As String

    If gbolErrorTrapOff = False Then On Error GoTo err_RunProcImpTbl


    strStoredProc = "dbo.File_Import_" & strSP
    SysCmd acSysCmdSetStatus, "Running " & strStoredProc
    Set cmd = New ADODB.Command
    cmd.ActiveConnection = cnn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = strStoredProc

    cmd.Execute

    'Check job status.
    strJob = "FRS_Import_" & strSP
    RunProcImpTbl = GetJobStatus(strJob, cnn)


exit_RunProcImpTbl:
    On Error Resume Next
    SysCmd acSysCmdClearStatus
    Set cmd = Nothing
    Exit Function

err_RunProcImpTbl:
    Select Case Err.Number
        Case Else
            gProcName = "RunProcImpTbl"
            glngErrNum = Err.Number
            gstrErrDescr = Err.Description
            glngLineNum = Erl
            Call ErrorLog("basImportProcess")
    End Select

    Resume exit_RunProcImpTbl

End Function

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com


---In MS_Access_Professionals@yahoogroups.com, <dbalorenzini@yahoo.com> wrote :

I have the following code that opens Windows Datalink Dialog so you an set connection strings.


Private Sub cmdOpenDataLink_Click()
Dim cn As ADODB.Connection


Dim MSDASCObj As MSDASC.DataLinks
Set MSDASCObj = New MSDASC.DataLinks

Set cn = New ADODB.Connection
MSDASCObj.PromptEdit cn

cn.Open
MsgBox "Connection opened successfully"
cn.Close
End Sub


Is it possible after the user creates the connection to pass it from the DataLink dialog back to my form?


Thanks,


Art Lorenzini

Sioux Falls, SD



 

 

__._,_.___

Posted by: wrmosca@comcast.net
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar