Creating Oracle DSN thru VB

I have done a project with VB 6 having back end as Oracle. I made it installable thru setup wizard. With that I can install the software on any system but have to create the DSN manually for connecting Oracle thru ODBC Administrater (Control Panel).

How can I automate the process of creating DSN?
rkumar121699Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rkumar121699Author Commented:
Edited text of question.
0
sudhi022299Commented:
try using the file dsn , instead of a system dsn. When you package your application include this file.

Regards,
Sudhi.
0
corvanderlindenCommented:
DSN-less connection

strConnect = "Provider=MSDAORA.1;" & _
  "Password=" & mstrPassword & ";" & _
  "Persist Security Info=False;" & _
  "User ID=" & mstrUserID & ";" & _
  "Data Source=" & mstrDataSource
   
mcnPKS.ConnectionString = strConnect
mcnPKS.ConnectionTimeout = 100   mcnPKS.CursorLocation = adUseClient
mcnPKS.Mode = adModeRead
'open the connection
mcnPKS.Open
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

sudhi022299Commented:
That would be ADO right ?

I don't know whether rkumar has used that.

Regards,
Sudhi.
0
zoltixCommented:
For conect to oracle vb6(native)
This code is great solution for connect oracle
code :

Public Property Get ConnectName() As String
    ConnectName = mstrConnectName
End Property
Public Property Let ConnectName(Name As String)
    mstrConnectName = Name
End Property
Public Property Get QueryName() As String
    QueryName = mQuery
End Property
Public Property Let QueryName(Name As String)
    mQuery = Name
End Property

Public Property Get ConnectDataBaseName() As String
    ConnectDataBaseName = mDataBase
End Property
Public Property Let ConnectDataBaseName(Name As String)
    mDataBase = Name
End Property
Public Property Get Passwordtxt() As String
    Passwordtxt = mPwd
End Property
Public Property Let Passwordtxt(Name As String)
    mPwd = Name
End Property

'//////////////////////////////////////////////////////////////////////////::
'/concatenation du login + password
'////////////////////////////////////////////////////////////
'/CE : mpwd + mstrConnect name
'/CS : La chaine remplie
Private Function fctstrLogin(Name As String, Pw As String) As String
    fctstrLogin = Name & "/" & Pw
End Function


'///////////////////////////////////////////////////////////////////////////
'/Connction a la base de donne par string
'/CE : Id PW Name de la base
'/CS : les classes sont modifié et la connection est etablie
Public Function ConnectString(Id As String, Pw As String, Name As String) As Integer
    Dim a As String
    Dim Err As Integer
    Dim strConnect As String
    Err = -1
    If Id = " " Then
        a = MsgBox("  No Id  ", vbExclamation, "BoError")
        Err = -2
    ElseIf Pw = " " Then
        a = MsgBox("  No Password ", vbExclamation, "BoError")
        Err = -3
    ElseIf Name = " " Then
        a = MsgBox("  No DATABASE ", vbExclamation, "BoError")
        Err = -4
    Else
        Err = 0
    End If
    If Err = 0 Then
        mstrConnectNam = Id
        mPwd = Pw
        mDataBase = Name
        a = MsgBox("Connect OK", vbInformation, "BoInformation")
        strConnect = fctstrLogin(Id, Pw)
        On Error GoTo NoOraConnection
        Set mOraSess = CreateObject("OracleInProcServer.XOraSession")
        Set mOraDatabase = mOraSess.OpenDatabase(Name, strConnect, 0&)
        a = MsgBox("Connect to base ", vbInformation, "BoInformation")
        GoTo Cont
NoOraConnection:
        a = MsgBox("Error de connection Oracle", vbCritical, "BoError")
        End
Cont:
    Else
        a = MsgBox("Connect Error", vbCritical, "BoError")
        End
    End If
End Function


'///////////////////////////////////////////////////////////////////////////
'/Connction a la base de donne Direct de l'Object
'/CE : Id PW Name de la base
'/CS : les classes sont modifié et la connection est etablie
Public Function ConnectDirect() As Integer
    Dim a As String
    Dim Err As Integer
    Dim strConnect As String
    Err = -1
    If mstrConnectName = " " Then
        a = MsgBox("  No Id  ", vbExclamation, "BoError")
        Err = -2
    ElseIf mPwd = " " Then
        a = MsgBox("  No Password ", vbExclamation, "BoError")
        Err = -3
    ElseIf mDataBase = " " Then
        a = MsgBox("  No DATABASE ", vbExclamation, "BoError")
        Err = -4
    Else
        Err = 0
    End If
    If Err = 0 Then
        strConnect = fctstrLogin(mstrConnectName, mPwd)
        On Error GoTo NoOraConnection
        Set mOraSess = CreateObject("OracleInProcServer.XOraSession")
        Set mOraDatabase = mOraSess.OpenDatabase(mDataBase, strConnect, 0&)
        'a = MsgBox("Connect OK", vbInformation, "BoInformation")
        'a = MsgBox("Connect to base ", vbInformation, "BoInformation")
        GoTo Cont
NoOraConnection:
        a = MsgBox("Error de connection Oracle", vbCritical, "BoError")
        End
Cont:
    Else
        a = MsgBox("Connect Error", vbCritical, "BoError")
        End
    End If
End Function


'///////////////////////////////////////////////////////////////////////////////
'/Execution et query
'/Ce : Object Connect String doit etre charge
'/Cs : modification de l'object avec la charge de l'object
'////////////////////////////////////////////////////////////////////////////////
Public Function Querry(strQuerry As String)
    Set mDynaset = mOraDatabase.DbCreateDynaset(strQuerry, 0&)
End Function

'///////////////////////////////////////////////////////////////////////////////
'/Execution et query
'/Ce : Object Connect String doit etre charge
'/Cs : modification de l'object avec la charge de l'object
'////////////////////////////////////////////////////////////////////////////////
Public Function QuerryDirect(strQuerry As String)
    Set mDynaset = mOraDatabase.DbCreateDynaset(strQuerry, 0&)
End Function

'///////////////////////////////////////////////////////////////////////////////
'/Execution et query
'/Ce : Object Connect String doit etre charge
'/Cs : modification de l'object avec la charge de l'object
'////////////////////////////////////////////////////////////////////////////////
Public Function fctDynatSet() As Object
    Set fctDynatSet = mDynaset
End Function

'///////////////////////////////////////////////////////////////////////////////
'/EXECUTE
'/Ce : str de la requete
'/Cs : modification de l'object avec la charge de l'object
'////////////////////////////////////////////////////////////////////////////////
Public Function EXECUTE_PROC_STOR(strQuerry As String)
    mOraDatabase.DbExecuteSQL (strQuerry)
End Function


'///////////////////////////////////////////////////////////////////////////////
'Fermeture
'/Ce : str de la requete
'/Cs : modification de l'object avec la charge de l'object
'////////////////////////////////////////////////////////////////////////////////
Public Function EndOfConnect()
    mOraDatabase.Close
End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
Which access method are you using?

If DAO, look at the RegisterDatabase method of the DBEngine object.

If RDO, loot at the rdoRegisterDatabase.

If ADO, you don't need DSN.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.