workgrupo file seems missing...and it is not(!)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does someone know what's wrong with this lines of code?

Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.ConnectionString = "provider='Microsoft.Jet.OLEDB.4.0'; Data
source='C:\Documents and Settings\rocco n forgione\My Documents\CLIENTS\GB
CASSANO\grant\database\collection\grant.mdb';userid='gestore';password='paolarucci';wrkgrp='c:\mdw_files\grant.mdw'"
cnn.Open

It miserably crash on the last line...
I just need to connect the database to work with its data.
But it sounds impossible. It says "the workgroup is missing or opened
exclusively by another user"
....now...it's only me working!!!!!!! and the path for the workgroup file is
correct as userid and password.
I have to say i really hate the connectionstring *thing*...but this seemed
SO easy (...which it should be not...and this confirm I'm not that good on
this stuff)

Any suggestion? (other than throwing away this messy through the window)
 
Public Sub TestConnection()

Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
" & _
"Settings\Brendan Reynolds\My Documents\Northwind.mdb;Persist
Security " & _
"Info=False;Jet OLEDB:System database=c:\dsdata\test.mdw"
'<--------------NB
cnn.Close

End Sub
 
Thanks!!
we improved...but not solved..
the line is now:
cnn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; Data
source=C:\Documents and Settings\rocco n forgione\My Documents\CLIENTS\GB
CASSANO\grant\database\collection\grant.mdb;userid=gestore;password=paolarucci;Persist " & _
"Security Info=False;Jet OLEDB:System database=c:\mdw_files\grant.mdw"

and now it says "not a valid userid or password"
Is'nt that cute?
 
There should be a space in "User ID".

The easiest way I've found to get connection strings right is to use the
Universal Data Link dialog. In recent versions of Windows, there's no UI
feature provided to create new UDL files, but you can create a new text file
and then change the extension from .TXT to .UDL. Double-clicking the file
will then open it in the Universal Data Link dialog. Use the dialog to build
and test the connection, then save it and open it in Notepad and copy the
connection string.

Here's an example that specifies the User ID and Password ...

Public Sub TestConnection()

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

Set cnn = New ADODB.Connection

'Persist Security Info = True only for testing/checking -
'will normally be set to False in production scenarios.
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password=TestPassword;" & _
"User ID=TestUser;" & _
"Data Source=C:\DSDATA\Northwind.mdb;" & _
"Persist Security Info=True;" & _
"Jet OLEDB:System database=c:\dsdata\test.mdw"
cnn.Open
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = cnn
.Source = "SELECT FirstName, LastName FROM Employees"
.Open
Debug.Print .Fields("FirstName") & " " & .Fields("LastName")
.Close
End With
cnn.Close

End Sub
 
thanks. Now it works!!!!
May I ask you were I can find some good stuff on how to manage the
connection string?
The help doesn't ...help that much (I haven't red anything of what you
used). or I'm using ti wrong.

Thank you very much.
 
The following web site has examples of many different types of connection
string ...

http://www.able-consulting.com/ADO_Conn.htm

But most of what I know about using ADO connection strings with Jet
databases comes from playing around with the UDL dialog, as I described in
my previous post. Check out the settings on the 'All' tab in that dialog
box. As always, it's wise to use copies of your application and data, and
the workgroup file too, when experimenting.
 
Back
Top