Thursday, January 7, 2016

Connection VB6.0 to MS SQL SERVER 2000

This is a simple code to connect vb6.0 with sql server, learn more...


First, make sure that your computer have been installed vb6.0 and ms SQL SERVER. Make a new project in vb6.0, Select Menu (Project => Reference) and check the Microsoft ActiveX Data Objects library (Sample : Microsoft ActiveX Data Objects 2.5 library) then click OK button.


Second, add a module (Select menu Project => Add Module) and paste code bellow :


Public Conn As New ADODB.Connection
Public Rec As New ADODB.Recordset 'berfungsi sebagai variabel penyimpan sementara
Public SQL As String ' variabel untuk menampung kode atau query sql
Public Server,Database,UserName,Password as String

Public Sub OpenConn()
On Error GoTo Handle
Set Conn = New Connection
Set Rec = New Recordset
With Conn
.ConnectionString = "Data Source=" & Server & ";Initial Catalog=" & Database & ";User Id=" & UserName & ";Password=" & Password
.Provider = "SQLOLEDB"
.Open
End With
Rec.Open SQL, Conn
Handle:
Msgbox"Any Problems !"
End Sub

Public Sub CloseConn()
Conn.Close
Set Conn = Nothing
End Sub

Try and enjoy it....

Any problems ? comment this article.
Share:

0 komentar:

Post a Comment

Kritik dan saran yang membangun kami harapkan!

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Blog ini sangat membantu bagi anda?