Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple connections using OpenConnection

Status
Not open for further replies.

Ranvier

Programmer
Jun 17, 2004
73
0
0
GB
I have an ADP project with a back end SQL Server. I'm using the following code to connect to the database. But this will only allow me one user to connect using the front end ADP. Once the first user has logged on a second user cannot seem to connect as it can't open anotehr connection. Does anyone know how I can overcome this or is there a way of specifying/allowing multiple connections?

Application.CurrentProject.OpenConnection _
"Provider=SQLOLEDB.1;" _
+ "Persist Security Info=false;" _
+ "Initial Catalog=" & strDatabase & ";" _
+ "Data Source=" & strServer & ";" _
+ "Integrated Security=SSPI;"


Many Thanks
 
try naming the connection and then checking its state

e.g.
'declare a public variable for the connection
public myCN as new adodb.connection

'Then have a procedure to open the connection - call this before each procedure which calls the database

public sub sbOpenDbConnection ()

if mycn.state = 0 then
mycn.Open "Provider=SQLOLEDB.1;" _
+ "Persist Security Info=false;" _
+ "Initial Catalog=" & strDatabase & ";" _
+ "Data Source=" & strServer & ";" _
+ "Integrated Security=SSPI;"
end if

end sub


This should eliminate opening another connection unnecessarily


"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top