|
-
March 16th, 2004, 01:54 AM
#1
DSN free code
Hi,
I have a small application in VB which writes some information onto Microsoft Access database tables. For this to happen, I have created a DSN referring the corresponding .mdb file.
To run my application on some other machine I need to create a DSN over there. This is going to be a tedious job.
Can anyone suggest me a method wherein I can access the database tables without the use of a DSN.
Any help/ideas in this regard would be highly appreciated.
Regards
Cufit
-
March 16th, 2004, 04:11 AM
#2
If you can map drive
And if you can have your access mdb in a shared folder,
and if clients may have rights to read wirte there, then you could
map on each client the folder where the mdb is and use
a built connection string that might be all te same for each client
Or you could have a component on server (=machine where
access is) that retrieve recordsets or write or update or delete,
and have clients referencing and using that component.
If mdb is on a machine like win2k or greater, you could take
advantage of Com+.
If not, you might have to fight with Dcom, in wich case you
might prefer the Dns strategy....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
March 16th, 2004, 04:47 AM
#3
cufit99,
You can access the database without the DSN, this is called a DSN-less connection. Below is a sample connection string for Access database using ADO Jet provider.
Code:
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=<the mdb path here>"
Busy 
-
March 17th, 2004, 06:00 AM
#4
Hi,
Thank you both Cimperiali and Thread1.
My application mostly runs over a private network, so having the mdb file in a shared folder is not feasible.
So, I tried to use the DSN less connection and it really worked well. Now I'm trying out ways to create an mdb file with the required tables programatically.
Thank You for your timely help.....
Regards,
Cufit
-
April 4th, 2004, 05:48 AM
#5
DSN free code
Why don't you try to change DSN from VB? All you have to do is to modify something in registry.
-
May 1st, 2004, 03:16 AM
#6
Hi
This thread came in a search I did.
My problem is after I make the DSN-less connection to the Access Database, I get a recordset with -1 RecordCount.
Here's the Code:
Code:
cnPhase1.Open GetConnectionString(strPhase1DB)
rsPhase1.LockType = adLockOptimistic
rsPhase1.ActiveConnection = cnPhase1
rsPhase1.Source = "Phase1"
rsPhase1.Open
...
Code:
Private Function GetConnectionString(filename As String) As String
GetConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & filename
End Function
I don't get any errors, just a -1 as rsPhase1.RecordCount.
When I open the Database with MS Access, go into the table "Phase1", I see 2 existing records.
What could be the problem?
Thanks in advanced.
-
May 2nd, 2004, 06:46 AM
#7
use cursorlocation = adUseClient for your connection object before opening it
-
May 3rd, 2004, 09:25 PM
#8
..and for CursorLocation = adUseServer (default), try to use cursor that supports the bookmarking (method Supports(adBookMark)) - Keyset and Static (adOpenKeyset and adOpenStatic) in the CursorType property of the recordset obj.
Busy 
-
May 4th, 2004, 07:03 AM
#9
Try MoveLast before RecordCount.
Code should be also secured with checking BOF and EOF properties.
aki999
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|