Loading

Connect to SQL Server 2008 through TCP / IP Using VB.NET 2008 Project

Submitted by: 


Hi this is Vb.net connect sql server using TCP/IP before run this program you need to install a vb.net 2008 and sql server 2008 here in example code:

Hi you need to do this
click all program/ ms sql server 2008 / configuration tool then click SQL server configuration manager
select you server name then rigth click properties you need to enable a TCP and IP add then Restart

"you need to do this VB.net is computer 1 and sql server is computer 2 same both installation of sql server"

Imports System.Data.SqlClient
Imports System.Data
Module Module1

Public Con As SqlConnection
Public constr As String
Public usertype As String

Public Sub main()

constr = "Data Source="IP add of computer" ,"TCP Port";Network Library=DBMSSOCN;Initial Catalog="databaseName; Trusted_connection=True"
Con = New SqlConnection(constr)
Try
Con.Open()
MsgBox("Server Connection is Open ! ")
Con.Close()
Catch ex As Exception
MsgBox("Sorry Can not open connection ! ")

End Try

End Sub
End Module



Download Code: 

Comments

emond's picture

5 globes for prince

emond sabiniano
System Developer-Software Consultant

globes what do u mean?

Thank you i have imformation how to connect vb.net to sql server of another computer

hello how do i connect the client to server in vb 2008....we propose a computerized voting system and we use vb 2008...pls help.

princenathan's picture

Hi you want to have a 1 server and more client...
you want to do this!!
Server(Sql server 2008 or Sql server 2012)
client (Vb 2008 or vb 2010)
learn about local coonection to
server connect the vb as client
sample Pc1 as server PC2 as client
if you want to connect the server as a global network
you need to host the database
anywhere you can connect the server!!
give your email and i send you the example that!! :)

)PrinceNathan(

just Send your msg at my yahoo account/FB: jonathan_200975@yahoo.com

System Developer and Web Developer

>Programming in The Future Technology<

nice posting. can i ask if you have sample of employee database program.

princenathan's picture

You can email me jonathan_200975@yahoo.com

)PrinceNathan(

just Send your msg at my yahoo account/FB: jonathan_200975@yahoo.com

System Developer and Web Developer

>Programming in The Future Technology<

Your idea is what i need for my system i tried to improved here in ofc.
Now i just ask you if you could help me for this, i have a server 2003 here and ms sql 2005. And i use Visual Basic 6.0 as my program application. I connect already the sql server for only local area but i also wanted to connect anywhere i want using TCP/IP. Kindly PM me. Thanks..

You can email me bratly02@yahoo.com

princenathan's picture

You need to host your database to internet for become a Global Network and you can connect anywhere!!!

)PrinceNathan(

just Send your msg at my yahoo account/FB: jonathan_200975@yahoo.com

System Developer and Web Developer

>Programming in The Future Technology<

mr. Price, thank you for your code, however im still having trouble.
my connection string is ;
Data Source= 58.167.**.**.,1433\.\SQLEXPRESS;Network Library=DBMSSOCN;Initial Catalog=northwind; integrated security=True

PLEASE HELP!,
william

Add new comment