Results 1 to 2 of 2

Thread: 2 Questions - Win2000

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 1999
    Location
    South Africa
    Posts
    22
    Hi there, thanks for taking the time to consider my problem.
    We are developing an app for our 3rd year IS course.

    We are running win2000 on our machines, but I cannot seem to get the code that works on win98 for adding DSN's to the ODBC system to work.

    The machine also refuses to show whether or not the PC is connected to a LAN (through code), like win98.

    Please advise me urgently.

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    This will create a DSN (for Access in this example).

    Place this in a module ...

    Code:
    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
    
    
    ' SQLConfigDataSource consts
    Public Const ODBC_ADD_DSN = 1          ' Add user data source.
    Public Const ODBC_CONFIG_DSN = 2       ' Configure user data source.
    Public Const ODBC_REMOVE_DSN = 3       ' Remove user data source.
    Public Const ODBC_ADD_SYS_DSN = 4      ' Add system data source
    Public Const ODBC_CONFIG_SYS_DSN = 5   ' Configure system data source
    Public Const ODBC_REMOVE_SYS_DSN = 6   ' Remove system data source
    Place this in a form ...

    Code:
    Dim lngRetVal As Long
    Dim strDriver As String
    Dim strPassword As String
    Dim strDSNName As String
    Dim strDBPath As String
    Dim strAttributes As String
        
      strPassword = "SomePassword"
      strDSNName = "SomeDSNName"
      strDBPath = "C:\Temp\SomeDB.mdb"
      strDriver = "Microsoft Access Driver (*.mdb)" & Chr(0)
      
      strAttributes = "DSN=" & strDSNName & Chr(0)
      strAttributes = strAttributes & "Uid=" & Chr(0) & "pwd=" & strPassword & Chr(0)
      strAttributes = strAttributes & "DBQ=" & strDBPath & Chr(0)
      
      lngRetVal = SQLConfigDataSource(0, intAction, strDriver, strAttributes)
    intAction will be one of the const's declared.
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width