|
-
Oct 8th, 2014, 12:55 AM
#1
Thread Starter
New Member
Connecting to SQL Server hostname from VB .net
Hello Experts. I need your help please
I have a VB .net program that I have been using for a while. The program is written using VB .net 2005. It access SQL server 2005 which is local on the same machine the program resides. I have been asked to connect to a 2012 server or 2008 using
" The server hostname SSQL02BLA1, I spoke with the DBA and he said that he connects to it via TCP/IP and doesn't use the name of the server instance."
In the past I used the following code to connect to the local server and everything works fine:
Imports System.Data.SqlClient
Public Class
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim DBadp As New System.Data.SqlClient.SqlDataAdapter
Dim command As New System.Data.SqlClient.SqlCommand
DBconn = New System.Data.SqlClient.SqlConnection
DBconn.ConnectionString = "Data Source=.;AttachDbFilename = " & str_data & ";Integrated Security=True;"
Dim dtclient As New DataTable
dtclient.Clear()
If DBconn.State = ConnectionState.Closed Then
DBconn.Open()
End If
DBadp = New System.Data.SqlClient.SqlDataAdapter("select * from clientdb", DBconn)
DBadp.Fill(dtclient)
DBconn.Close()
End Sub
End Class
I need your help on what to do to change the connection as requested to SQL 2012 and connect to the server hostname SSQL02BLA1.
Also, do I need to make any other changes on the code when accessing data?
In the past I did a direct access now the request is for a remote access.
PLEASE HELP thanks in advance!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|