Pages

Subscribe:

Ads 468x60px

Sunday, July 25, 2010

What is the Connection String that I use in SQL Server 2000 to connect with VB.NET?

When you make a project in VB.NET and use database then a connection string is needed to connect VB.NET with database. In the following I show a connection string needed when we use SQL Server 2000 as database. Here this string is made for database "Moto".



So please lets go:

Imports System.Data.SqlClient
Module Module1
    Public sttr1 As String
    Public dbconc As SqlConnection
    Public dbrec As SqlCommand
    Public Sub connect()
        sttr1 = "Data Source=localhost;Initial Catalog=Moto;Integrated Security=True"
        dbconc = New SqlClient.SqlConnection(sttr1)
        dbrec = New SqlClient.SqlCommand()
        dbrec.Connection = dbconc
        dbconc.Open()
    End Sub
    Public Sub disconnect()
        dbconc.Close()
    End Sub
End Module

This code works 100%. I generally use it and made a lot of projects with that. For this reason, try with it. If you find any bug here or you get a better then please share it. Thanks for reading this post.

0 comments:

Post a Comment