954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Connect VB Client application with SQL Server using TCP Connection (LAN)

Hi, I've been Searching the Net for hours now, and i can't really seem to find anything clear and straight to the point.

I need to create a Server/Client application using VB.net 2008, it's actually my first time to have a database on another computer. So I first searched the internet for the things i need to make this software.

-MSSQL Server 2008 (Not R2)
-Management Studio
-Vb.Net 2008 Express Edition
-A Desktop (Client)
-A Laptop (Server)
- 1 Crossover Cable

What i have managed to do so far:

1. I have Connected and Established a connection between the two Computers and "Pinged" them using cmd> ping 192.168.X.X and they both replied.

2. I Created a Database on the Server(Laptop) using MSSQL Server 2008 and named it "Network18".

3. I made a Simple Form and a button in the Client (Desktop).

4. I wrote this code in order to test the connection between the two computers..

Imports System.Data.SqlClient
Public Class Form1
    Dim Sqlcon As SqlConnection
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Sqlcon = New SqlConnection("Data Source=MyComputerName\SQLEXPRESS;Initial Catalog=Network18;Integrated Security = True")
        Sqlcon.Open()
    End Sub
End Class


("Please do check if i'm missing something")The Problem:

I don't think something is wrong with my code, but every time I try to execute the software from the "Client", in order for me to test if i made the connection successfully, i get this error..

Login failed for user 'MyComputername\Guest'.

so i searched the net for some clues and read about an article about the the authentication of my database. so i checked again my authentication and i saw that it's set in Windows Authentication, which i think is correct. but when i try to remove the "\SQLEXPRESS" together with the mycomputername it just gives the network connection error.

I tried turning off my AV + my Firewall, Made some changes in the users in MSSQL management studio, tried Reseting the SQL Server from services.msc.. still the same error.

so, can anyone help me on this one.. i've spent all morning trying to figure out where i went wrong. any help will be appreciated thanks!

bwaha
Newbie Poster
11 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

U need to create the Service account i guess. Which can be passed as user name and password from ur application so that all the user in LAN will have access to server.
or Pass the credentials to server i.e: User name and password

Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 
U need to create the Service account i guess. Which can be passed as user name and password from ur application so that all the user in LAN will have access to server. or Pass the credentials to server i.e: User name and password

Correct me if im wrong sir, base on what i can understand is basically i have to set a username and password in MSSQL Server to use in my application in the connection string in order to get pass that error?

bwaha
Newbie Poster
11 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

first install sql server management studio , then make sure server computer is connect with your computer , then give that server name like server/sqlexpress , then connect it ,

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 
first install sql server management studio , then make sure server computer is connect with your computer , then give that server name like server/sqlexpress , then connect it ,

Yes, I've already done that. the thing is when i'm using the code above to check for connections with my soon to be software using vb.net 2008, the error "Login failed for user 'MyComputername\Guest'" pops up. that's my problem.

bwaha
Newbie Poster
11 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

hello!
you have to make the login in server for this client then connect it ,

Regards

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: