Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to joint SQL Client(another PC) to SQL Server for access data, Can u help me by coding VB.NET?

What I have tried:

I can't browse by Server Explorer and Coding.
I don't know problem
Posted
Comments
Kornfeld Eliyahu Peter 8-Feb-16 4:44am    
'join'? Do you mean connect?
Do you have any code? Any error?
savin phat 10-Feb-16 3:34am    
do not error anything by code, but I can't connect to server via Lan.
Help me please.

1 solution

Hard to tell what your problem is from this.

Assuming (correct me if I am wrong) you would like to access data on an SQL server from a VB project?

Very primitive example:

Import System.Data.SqlClient 


Sub AccessDatabase

   Dim oSQLConnection As New SqlConnection
   Dim oSQLCommand As SqlCommand
   Dim oSQLDataReader As SqlDataReader

   oSQLConnection = New SqlConnection("Initial Catalog=Database; _
                         User ID=UserID ;Data Source=ServerName;Password=Password)
   oSQLConnection.Open()

   oSQLCommand = New SqlCommand("SELECT * FROM table", oSQLConnection)
   oSQLDataReader = oSQLCommand.ExecuteReader

   etc...

End Sub


Hope this helps but please provide more information if this is not what you needed to know.
 
Share this answer
 
Comments
savin phat 11-Feb-16 22:37pm    
thank for your answer.
if we use SQLServer on Network, how we write
oSQLConnection = New SqlConnection("Initial Catalog=Database; _
User ID=UserID ;Data Source=ServerName or \\ServerName or ....;Password=Password)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900