Discussion Locked

database connection without using DSN

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi,
i am interacting with database, which is lying on server, through vc++ application.
at present i am using "SQLConnect()" to connect my application with oracle database in which one of the parameters is "Data Source Name(DSN)".
is there any other way to connect it with oracle without using DSN or just using ip address and port number of the server or something like that??
in short i dont want to use DSN.
my application is already through so i cant go for the major changes inthat, so plzz suggest me some minor changes by which i can ommit the DSN stuff.
waiting for ur reply,
with best regards,
prakash..

5 replies

by jay eckles

I would suggest going to 4guysfromrolla.com and searching for "DSNless connection" It's easily done in Visual Basic, and I'm guessing it's not much different in VC++. If it is, you can always write a dll in Visual Basic and use it from your VC++ application.

This is a FAQ.

Good luck.

Jay Eckles
www.jayeckles.com

by satheesh

hi Prakash,

U can use Provider to connect

pls check it out....

Enum BackEnd

sqlserver
MSAccess
ODBCAccess
ODBCSql

End Enum

Public Function OpenConnection(cnGeneral As ADODB.Connection, Provider As BackEnd, database As String, Optional user As String, Optional pwd As String, Optional dsnName As String)

Set cnGeneral = New ADODB.Connection
Dim X As String

If Provider = sqlserver Then

X = "sqloledb.1" cnGeneral.Open "Provider= '" & X & "'" & ";Persist Security Info=True;User ID= '" & user & "'" & ";Password= '" & pwd & "'" & ";Initial Catalog= '" & database & "'" & ";Data Source=131.107.2.109;Connect Timeout=0"

ElseIf Provider = MSAccess Then

X = "Microsoft.Jet.OLEDB.4.0"
cnGeneral.Open "Provider= '" & X & "'" & ";Persist Security Info=False;Data Source= '" & database & "'"

ElseIf Provider = ODBCAccess Then

X = "MSDASQL.1"
cnGeneral.Open "Provider= '" & X & "'" & ";Persist Security Info=False;Data Source= '" & dsnName & "'" & ";Connect Timeout=0;Initial Catalog= '" & database & "'"

ElseIf Provider = ODBCSql Then

X = "MSDASQL.1" cnGeneral.Open "Provider= '" & X & "'" & ";Password= '" & pwd & "'" & ";Persist Security Info=True;User ID= '" & user & "'" & ";Data Source= '" & dsnName & "'" & ";Connect Timeout=0;Initial Catalog= '" & database & "'" End If

Exit Function

End Function

cool man

With regards
S.Satheesh

This discussion is closed to new replies.