|
|
|
|
|
Dicas
|
|
Visual Basic (Banco de Dados)
|
|
|
Título da Dica: Criar e remover DSN (run-time)
|
|
|
|
Postada em 11/3/2003 por Ricardo
Public Sub CriaDSN(driver As String, server As String, description As String, dsn As String, database As String) Dim intRet As Long Dim strDriver As String Dim strAttributes As String ' String de conexão strDriver = driver strAttributes = "SERVER=" & server & Chr$(0) strAttributes = strAttributes & "DESCRIPTION=" & description & Chr$(0) strAttributes = strAttributes & "DSN=" & dsn & Chr$(0) strAttributes = strAttributes & "DATABASE=" & database & Chr$(0) intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes) If intRet = 0 Then MsgBox "Falha na criação do DSN para MySQL", vbCritical, "Falha ODBC" End Sub
Public Sub RemoveDSN(driver As String, dsn As String) Dim intRet As Long Dim strDriver As String Dim strAttributes As String ' Executar exclusão do DSN strDriver = driver strAttributes = "DSN=" & dsn & Chr$(0) intRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, strDriver, strAttributes) If intRet = 0 Then MsgBox "DSN não foi eliminado!" End Sub
|
|
|
|
|