Developers community number 1 connection string reference

HOW TO CONNECT SQL7 SERVER TO CLIENT

Posted 2010-05-21 07:16
by SHEKHAR PRASAD
in the Composite Information Server Forum
I HAVE TO WORK IN VB .NET 2003 IN DATABASE SQL SERVER 7
I HAVE TO CONNET ANOTHE SYSTEM ? WHAT PROSSES CAN U HELM ME
Reply 2010-05-24 14:37
by Max Wikström
in the Composite Information Server Forum
Something like this could be a start...
Change the connectionstring and the table name in the following example.

Imports System.Data.SqlClient
Public Class Form1 Inherits System.Windows.Forms.Form
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim dr As New SqlDataReader()
'declaring the objects need
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles MyBase.Load
myConnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=pubs")
'establishing connection
Try
myConnection.Open()
'opening the connection
myCommand = New SqlCommand("Select * from yourtable", myConnection)
'executing the command and assigning it to connection
dr = myCommand.ExecuteReader()
While dr.Read()
'reading from the datareader
MessageBox.Show(dr(0).ToString())
'displaying the data from the table
End While
dr.Close()
myConnection.Close()
Catch e As Exception
End Try
End Sub
End Class
Selected Articles
Copyright © 2012 ConnectionStrings.com   |   All Rights Reserved   |   Powered by CSAS   |   Send feedback, articles, requests and more connection strings here.