I'm trying to connect to a SQL Server DB over a LAN... I would like to know how to do this, because i've searched a lot but haven't found too much help...If you know the code of how to do this it would be even better. THANK YOU
Option Strict Off
Option Explicit On
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim DBconnect As New SqlConnection
Dim DBadp As New SqlDataAdapter
Dim dbcom As New SqlCommand
Dim A As New DataSet
Dim B As New DataSet
Load event of form
If DBconnect.State = ConnectionState.Closed Then
DBconnect.ConnectionString = "Provider=sqloledb;DRIVER=SQLServer;
SERVER=SQLservername;UID=xxxx;PWD=xxxxxxxx;DATABASE=YourDatabasename"
DBconnect.Open()
End If
dbcom.Connection = DBconnect
DBadp.SelectCommand = dbcom
dbcom.CommandText = "select * from MyTable order by id"
DBadp.Fill(A, "mytable")
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.