borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Build a database system?)Next Topic (Combine Two Tables Into One) New Topic New Poll Post Reply
AndreaVB Forum : Database : remote database Solved Topic
Poster Message
007
Level: Scholar

Registered: 14-08-2003
Posts: 30

icon remote database

hi

somebody help me,  i'm trying to develop a database program, it's a server-client application. i don't know how to connect client to the server database. i dn't know the connection string.

please give me sample codes  

____________________________
Make your dreams REAL!

20-03-2006 at 01:41 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: remote database

What type of server database are you trying to connect to?

Here is a list of providers:

http://www.carlprothman.net/Default.aspx?tabid=81

____________________________
If you find the answer helpful, please mark this topic as solved.

20-03-2006 at 02:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

i'm using microsoft access database


____________________________
Make your dreams REAL!

20-03-2006 at 03:41 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: remote database

Hi,
Here's an easy way to find out what the connnection string is for any database you are working with. Just put an ADO DataControl onto a Form, get the Property Page and click on "Use Connection String" then click the "Build" button. This will walk you through the connection, then after you have finished you just copy the Connection String and paste it into your code.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

20-03-2006 at 08:47 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: remote database

Did you even look at the site I gave you? There you have OleDB provider for MS access, and have an example if database if located on a network share.

____________________________
If you find the answer helpful, please mark this topic as solved.

20-03-2006 at 06:04 PM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

can i use IP address for the connection of database in a remote PC instead of a shared Drive? how?
i'm trying to use the ff codes but it doesn't work

oConn.Open "Provider=MS Remote;" & _
           "Remote Server=http://myServerName;" & _
           "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\mydb.mdb", _
            "admin", ""



____________________________
Make your dreams REAL!

23-03-2006 at 12:57 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: remote database

Did you actually read mine and Gorans posts

The info is all there for you.

If you are connecting to a MS Access database then the database needs to be located on a on a "server" computer (which in the case of Access does not need to be running a "server" Operating System) in a Directory (Folder) which has been enabled for "Sharing".
You then just point your connection to the server and share name.
If you have protected the entire database with a Password then you need to include that in the Connection String. If you have set up particular Users in the Database Workgroup each with a login Password then you must include the path to the Workgroup Database together with the User Name and Password (";Jet OLEDB:System Database=" & StrPathToLocation & "\MyWorkgroupSystemDB.mdw, " & Username & "," & "Password") but if you are just using the standard "Admin" Workgoup User without a login Password then you do not need to include anything in the Connection String.



Dim strCNN As String
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strPath As String

strPath = "\\MyServerName\ShareName"

strCNN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "\MyDatabase.mdb;Persist Security Info=False;Jet OLEDB:" _
& "Database Password=MyDatabasePassword_IF_SET"

Set cnn = New ADODB.Connection
cnn.CursorLocation = adUseClient
cnn.Open strCNN
Set rst = New ADODB.Recordset
rst.Open "NameOfDatabaseTable", cnnLicence, adOpenDynamic, adLockOptimistic

rst.MoveFirst




____________________________
multi-tasking - the ability to hang more than one app. at the same time.

23-03-2006 at 09:53 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: remote database

quote:
oConn.Open "Provider=MS Remote;" & _
           "Remote Server=http://myServerName;" & _
           "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\mydb.mdb", _
            "admin", ""


You never said that this database is not located on LAN network, which makes great difference. ADO communicates to remote server via RDS DataFactory, which I never used myself, but you should read about it, since I think I have read that this tehnoloogy has some major security holes.

Anyway, back to your problem. It should be

Remote Server=http:\\ ' not the Remote Server=http://

[Edited by Goran on 23-03-2006 at 03:16 PM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.
23-03-2006 at 02:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

i connected already my client program to the remote database, but the problem is when the server program is open i can't connect the client program to the database program. if i close the the server program then the client can connect. meaning i cannot open the database when the server and client program is running or open. is there any solutino for this?   

____________________________
Make your dreams REAL!

24-03-2006 at 02:15 AM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

attached herewith is the error message i have encountered everytime i open the client program if the server program is also open, else if server is close there's no problem.

Please see the attach file

____________________________
Make your dreams REAL!

____________________________
Attached:
errorconnection.bmp 79 KB (Downloads: 7)

24-03-2006 at 05:27 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: remote database

Hi,
When you open the mdb file on the Server do you open it with Access or from a VB6 program.? It is possible that you are opening it in "Exclusive" mode.
It would help to know what you are using to open the mdb file, if it is VB6 what is your connection string, and what is the Operating System that is running on the "Server" computer?


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

24-03-2006 at 12:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

i'm opening it with vb6. my programs are two. i have a vb6 program for Server and another program for client. i have only one Access database. these two programs used the said database. but the problem is only one program can open the database.

i'm using Windows 98 for these two programs. all computer used the windows 98? i don't have OS for the server like windows NT or Windows 2003 server

this is my connection string. drive c is shared.

is it possible to used the IP address for the connection string?


Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\O07\c\intranet\Database\dbUser.mdb;Persist Security Info=False

[Edited by 007 on 28-03-2006 at 01:23 AM GMT]

____________________________
Make your dreams REAL!

28-03-2006 at 01:18 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: remote database

Hi 007

Your c drive is shared, what is the sharename is it also c?

If not thats what you need to put in the connection string instead of c.

Also see if you can access the drive from the other pc using explorer.


And yes you can use an ip address, just replace the computer name with it.

Steve  

28-03-2006 at 08:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: remote database

Hi 007,
Further to what Steve says, and purely as a suggestion, it would be better to place the "Share" on the "intranet" Folder rather than the root of your hard drive, it is never good practice to "Share" the whole of your computer with anyone. Having said that, I am assuming that you have the correct share name in your Connection String as you are able to connect the "Client" program when the program running on the "Server" PC does not have the database open. Windows98 does not have any Share settings that limits the number of concurrent connections (like XP does) so it cannot be this that is preventing you from opening the file. Access does not have any problems with multiple connections, so again this cannot be the problem. The only other thing I can think of is that you may have set the default open mode (in Access Tools/Options/Advanced) to Exclusive, although this should not have any effect if you are opening from VB6 with ADO.
Have you tried opening the database on two different computers using Access, if you can do that then there is something in your VB6 code that is causing the problem.



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

28-03-2006 at 01:18 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: remote database

If you open a database on a client PC, are you able to open the database on server afterwards? Or the access is denied only on client PC?

____________________________
If you find the answer helpful, please mark this topic as solved.

29-03-2006 at 11:44 PM
View Profile Send Email to User Show All Posts | Quote Reply
007
Level: Scholar

Registered: 14-08-2003
Posts: 30
icon Re: remote database

i already solved the problem. thnks for all the help Goran, GeoffS, steve_w,

____________________________
Make your dreams REAL!

30-03-2006 at 01:28 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : remote database Solved Topic
Previous Topic (Build a database system?)Next Topic (Combine Two Tables Into One) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder