Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra connectivity to a SQL or MySQL database

Status
Not open for further replies.

tps14334

Technical User
Dec 8, 2008
21
US
Does anyone have any examples or documentation on getting extra to connect to a SQL or MySQL database, including how to add, update, and move through the records?
 



Hi,

Extra cannot connect. But you can write VBA code, using ADO to access you database.

this happens to be a function I wrote to return a value, but the principle is the same. You just need a library reference to Microsoft ActiveX Data Object n.m Library
Code:
Function GetPartPriorty( _
        sPN As String) As String
'--------------------------------------------------
'SkipVought
'2007-08-02
'--------------------------------------------------
' Access: DB2.SFCS.READ
'--------------------------------------------------
':this function returns PRIPART for a given Part Number
'--------------------------------------------------

    Dim sConn As String, sSQL As String, sServer As String
    Dim rst As ADODB.Recordset, cnn As ADODB.Connection
    Dim lLineCtrl
    
    Set cnn = New ADODB.Connection
    
    sServer = "DB2OLEDB"
                 
    cnn.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _
                "User ID=;" & _
                "Extended Properties=""DSN=Shadow Direct DB2P 32-bit;" & _
                "UID=;PORT=6800;HOST=mvsb1;SUBSYS=DB2P;CPFX=SHADOW;AT=YES;" & _
                "DP=%;AF=YES;MXBU=40960;AUST=NO;CNTM=120;"""

    
    Set rst = New ADODB.Recordset
    
'    sSQL = "SELECT Qty, Current_Op, Location, sf_cc, sf_oper, mach_grp "
    
    sSQL = "SELECT PRIPART "

    sSQL = sSQL & "FROM CAP.T_PART_NUMBER "
    
    sSQL = sSQL & "WHERE (PARTNO='" & Trim(sPN) & "')"
    
    rst.Open sSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText
                          
    rst.MoveFirst
    
    
    If rst(0) <> "" Then
        GetPartPriorty = rst(0)
    End If

    rst.Close
    cnn.Close
    
    Set rst = Nothing
    Set cnn = Nothing
End Function


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top