SQL Server Security Vs Windows

B

Becks

Hey Guys,

In previous ADP's I've used Windows security rather than SQL Server with a
set of routines to set up a global ADO connection.
However in my current project, I am working using straight SQL Server
security and the open connection routine fails when opening the connection
as the CurrentProject.Connection does not hold the password information.

Can anyone help with how to get round this? (Code below)
Thanks,
Becks


___________________________________________________
Public Function OpenConnection() As Boolean
On Error GoTo ErrorHandler
' Opens Global ADO Connection, if it isn't already open.

Dim boolState As Boolean

If gcnn Is Nothing Then
Set gcnn = New ADODB.Connection
End If

If gcnn.State = adStateOpen Then
boolState = True
Else
gcnn.ConnectionString = CurrentProject.Connection
'gcnn.ConnectionString =
"Provider=Microsoft.Access.OLEDB.10.0;Persist Security Info=True;Data
Source=OTUSLONS2;Integrated Security=SSPI;Initial Catalog=USAF;Data
Provider=SQLOLEDB.1"

gcnn.Open
If gcnn.State = adStateOpen Then
boolState = True
Debug.Print "Global Connection Opened : " & Time()
Else
boolState = False
End If
End If

OpenConnection = boolState


ExitHandler:
Exit Function
ErrorHandler:
OpenConnection = False
If ERR_HANDLER Then Stop
If Err.Number = 430 Or Err.Number = -2147467259 Then
RunCommand acCmdConnection
Resume
Else

Select Case intErrorDisplay(Err.Number, Err.Description,
"OpenConnection", "", True, OBJECT_NAME, True)
Case 1: Resume
Case 2: Resume Next
Case 3: WarnHourOff: End
Case 4: Stop: Resume
Case Else: Resume
End Select
End If
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top