|
|
|
|
|
Dicas
|
|
Visual Basic (Banco de Dados)
|
|
|
Título da Dica: Criando DSN para um Banco de Dados Access via código
|
|
|
|
Postada em 20/3/2002 por William
Option Explicit
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long
Private Const ODBC_ADD_DSN = 1 ' Adiciona o Data Source Private Const ODBC_CONFIG_DSN = 2 ' Configura o Data Source Private Const ODBC_REMOVE_DSN = 3 ' Apaga o Data Source Private Const vbAPINull As Long = 0& ' NULL Pointer
Public Sub CreateDSN(sDSN As String) Dim nRet As Long Dim sDriver As String Dim sAttributes As String
sDriver = "Microsoft Access Driver (*.mdb)" sAttributes = sAttributes & "DATA SOURCE=C:\Arquivos de programas\Projetos\Sistema de Iss\sisiss.mdb" & Chr$(0) sAttributes = sAttributes & "DESCRIPTION=Banco de Dados do Sistema de Impostos e Taxas" & Chr$(0) sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0) sAttributes = sAttributes & "UID=Admin" & Chr$(0) sAttributes = sAttributes & "PWD=" & Chr$(0)
nRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, sDriver, sAttributes)
End Sub
|
|
|
|
|