Hi To All,
I am a newbie.
I have 4 computers that I want to connect together as a LAN. I have a switch and ready cables.
One of the computers C1 will have a sqldatabase to be accessed by the other computers C2,C3 and C4.

  1. How do I connect the computers so that my VB.net application should access the database?
  2. How do I set the connection string in the VB.net application to communicate with database in C1 when I have deployed it?

I intend to create a setup for the vb.net application and deploy it to C1, C2, C3 and C4.

Please give me a step-by-step explanation with examples. I know I need to make use of IP addresses.
No security configurations required.

Also refer to useful links if any.
Thanks

Comments

How do I connect the computers so that my VB.net application should access the database?

If you mean how to create a network, there are a lot of options. The easiest approach is to buy a network switch with at least 4 ports and plug each computer into a switch port. Assign an IP address to each computer on the same subnet.

How do I set the connection string in the VB.net application to communicate with database in C1 when I have deployed it?

In the connection string, for the target server, you can specify the computer's netbios name if the 4 computers are on the same subnet, or the FQDN (fully qualified domain name) if this is part of a larger network with DNS, or the target IP address, if you are just doing this as a test and just need to quickly set this up.

For the connection:

Dim con as New MysqlConnection
Dim connectionstring As String

con = New MysqlConnection
connectionstring = ("Server = 127.0.0.1; User = root; password = mypassword; database = databasename")
con.ConnectionString = connectionstring 'the one defined in the previous line

con.open 'open the connection

'do what you want to do

con.close 'close the connection

(My code is for mysql, but i hope it works with SQL too.)
Try it and come back here if there is anything.

I have got some information as to how to connect the LAN similar to what you say. That I will do because I have a 4-port switch and cables.
My current connection string is
Conn.ConnectionString = "Server=blacklaptop;database=schooldbase;Trusted_Connection=True;"
I intend to change it to
Conn.ConnectionString = "Server=127.0.0.1;database=schooldbase;Trusted_Connection=True;"
hoping that it works with the connection and hoping that a firewall issue doesnt stop it.
Will come back from my journey and try, then get back here.
Thanks
Ohh
What if I create a (startup) form that specifies the database connection to my project's sql database so that i don't have to build it directly into my project code. In future the project may run in another LAN. Is That good?

Edited 3 Years Ago by gbhs

This article has been dead for over six months. Start a new discussion instead.