Re: Register Database to ODBC DSN Database by VB program

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Mon, 13 Feb 2006 10:26:05 +0300, Stas <stsn2000@xxxxxxx> wrote:

¤ Hello all!
¤ I need register my Database (MDB) to ODBC DSN Database by VB programm
¤ Where I can found example!

If I understand your question you want to create an ODBC DSN for an Access database:

Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const ODBC_ADD_SYS_DSN = 4 ' Add System DSN
Private Const vbAPINull As Long = 0& ' NULL Pointer

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

Dim intRet As Long
Dim strDriver As String
Dim strAttributes As String

strDriver = "Microsoft Access Driver (*.mdb)"
strAttributes = "DESCRIPTION=MyDSN" & Chr$(0)
strAttributes = strAttributes & "DSN=MyDSN" & Chr$(0)
strAttributes = strAttributes & "DBQ=e:\MyDocuments\db1.mdb" & Chr$(0)

intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, strDriver, strAttributes)


Paul
~~~~
Microsoft MVP (Visual Basic)
.



Relevant Pages

  • Re: Please Help Me in Visual Basic 6.0 SP6
    ... Dim dbPath As String ... Above is my programming where in this programming, ... how can i indicate myself which one i'm gonna insert to the database. ... > ¤ solution where as somebody can help me where to start. ...
    (microsoft.public.vb.database)
  • Re: Connection question
    ... recordset using the connection, the record count property was -1. ... How do I specify the cursor location propery in the connection string? ... > ¤ Hello, ... The object being that I want the connection to fail if the database is ...
    (microsoft.public.vb.database.ado)
  • Re: Compact and Repair
    ... ¤ Hi ... Public Function CompactDB(pFileName As String) As Boolean ... If your source database has a database password then you should use the following: ...
    (microsoft.public.vb.database.ado)
  • Re: Sql statement for OLE objects
    ... ¤ Ok, here is a way that I can get around what I am trying to do. ... Save the filelocation as a string into the database. ... ¤ When calling the report ...
    (microsoft.public.vb.database.ado)
  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)