I've included sample code below and you can use this with Visual Studio 2003. Make sure you make references to System.Data and System.Data.SqlClient in your class file. The crucial line is SqlConnection("server=oursqlserver;uid=sa;pwd=sapassword;database=master;") which contains the connection string. 'server' is the machine name of your SQL Server (e.g. SQLSERVER1, PLUTO, GSSQ1123); 'uid' is the Sql Server username, I recommed using "sa" (Sql Server Admin login) just as a test as you have higher chances of connecting as "sa"; 'pwd' is the associated password; 'database' is the database name you want to connect to, I've used "master" in this case as the database is guarenteed to exist in your Sql Server
[C#
using System.Data
using System.Data.SqlClient
public class WebForm1 : System.Web.UI.Page
private void Page_Load(object sender, System.EventArgs e
SqlConnection connection = new SqlConnection("server=oursqlserver;uid=sa;pwd=sapassword;database=master;")
// Open connectio
connection.Open()
// Perform all db operations her
// Cleanu
connection.Close()
connection = null
[Visual Basic
Imports System.Dat
Imports System.Data.SqlClien
Public Class WebForm
Inherits System.Web.UI.Pag
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Dim connection As New SqlConnection("server=oursqlserver;uid=sa;pwd=sapassword;database=master;"
' Open connectio
connection.Open(
' Perform all db operations her
' Cleanu
connection.Close(
connection = Nothin
End Su
End Clas
====
Rasika Wijayaratn