[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

putting up DSN in vb6

Posted on 2004-08-05
3
Medium Priority
?
711 Views
Last Modified: 2013-12-25
g'day, i have read other people's questions about putting up DSN, and used some code in them. i find when i use the code, it's puts up the DSN that does not point to a database.

so it works, but just doesn't select the database. it's an access database. here is the code i use.

Public Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
          (ByVal hwndParent As Long, ByVal fRequest As Long, _
          ByVal lpszDriver As String, ByVal lpszAttributes As String) _
          As Long

      'Constant Declaration
      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 a new system data source
      Private Const vbAPINull As Long = 0


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

      strDriver = "Microsoft Access Driver (*.mdb)"
      strAttributes = "SERVER=SomeServer" & Chr$(0)
      strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
      strAttributes = strAttributes & "DSN=RM TEMP" & Chr$(0)
      strAttributes = strAttributes & "DATABASE=" & App.Path & "RM.mdb" & Chr$(0)

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

thanks.
0
Comment
Question by:stromberg45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11726506
I think you forgot a \

strAttributes = strAttributes & "DATABASE=" & App.Path & "\RM.mdb" & Chr$(0)
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 11726530
shouldn't it be:
strAttributes & "DESCRIPTION=Temp SN" & Chr$(0)
strAttributes = strAttributes & "DSN=RM TEMP" & Chr$(0)
strAttributes = strAttributes & "DBQ='" &  App.Path & "\RM.mdb'" & Chr$(0)
strAttributes = strAttributes & "UID=username" & Chr$(0)
strAttributes = strAttributes & "PWD=password" & Chr$(0)
0
 

Author Comment

by:stromberg45
ID: 11749636
thansk for that emoreau, worked perfectly !!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question