Форумы HiProg.com - MS ACCESS, VBA, VB

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

ник: osmor
Option Compare Database
 
Option Explicit
 
'Const ODBC_ADD_SYS_DSN = 1      'Add a user data source
Const ODBC_CONFIG_SYS_DSN = 2    'Configure (edit) data source
Const ODBC_REMOVE_SYS_DSN = 3    'Remove data source
Const ODBC_ADD_SYS_DSN = 4       'Add a system data source
 
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
                    
 
Function Build_SystemDSN()
  
    Dim Driver As String
    Dim Ret As Long
    Dim Attributes As String
 
    Driver = "SQL Server"
    'attributes are the connection information
    
    Attributes = "server=ANSRLTR" & Chr(0)
    Attributes = Attributes & "DSN=DSN_Temp" & Chr(0)
    Attributes = Attributes & "Database=ANSRLTR_Prod" & Chr(0)
    'use this line if you want to use the users name and password
    'Attributes = Attributes & "Trusted_Connection=Yes" & Chr(0)
    'use this line if you are adding a username and password
    Attributes = Attributes & "Uid=Temp;" & Chr(0) & "Pwd=TempID" & Ch(0)
 
      Ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)
   
   
   'ret is equal to 1 on success and 0 if there is an error
   If Ret <> 1 Then
       MsgBox "DSN Creation Failed"
   End If
 
 
End Function


Ваше имя:

Пароль:

Цитировать: [quote][/quote] Код: [code][/code]
Жирный: [b][/b] Наклонный: [i][/i]
URL: [url][/url] 

Сообщение:

 Размер файла не более 50 Кбт. Большие файлы можно размещать на www.slil.ru

Прикрепить:

 

Для вставки смайлов в текст щелкните по значку.