vba ADO
Function GetCon(DataSource As String, Optional WithTitle As Boolean = True, Optional Password As String = "") As Connection If DataSource = "" Then Set GetCon = Nothing Exit Function End If Dim hdr As String If WithTitle Then hdr = "yes" Else hdr = "no" End If On Error GoTo E Dim con As New Connection With con .Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;hdr=" & hdr & "';Data source=" & DataSource & ";Jet OLEDB:Database Password=" & Password & ";Mode=ReadWrite;" End With Set GetCon = con Exit Function E: Set GetCon = Nothing End Function Function ColseCon(ByRef con As Connection) If con.State <> adStateClosed Then con.Close Set con = Nothing End If End Function
我学习JAVA的母校