VB 6.0 - SQL Server Connection

This Tutorial Visual Basic 6.0 how to connect Database SQL SERVER
  • Step 1: Create database and table in SQL SERVER
  • Step 2 : Design form in VB 6.0

#Step 1 :
Open Your SQL Server Application


Create Database : MYDB
Create Table : TBL_PRODUCT
Insert data in table : tbl_product

Click Control Panel in Your Computer
Search ODBC
Click ODBC
Click Add
Choose SQL Native Client
Click Next
Click Next
Click Next - Finish - OK
#Step 2 :
Open Visual Basic 6.0
Standard EXE - Open
Add component
Click Apply - OK
Design Form1 like below picture
save your project inside Folder VB6Access2003
click here for VB 6.0 - MySQL Connection
and then place code below in form1 :
Dim Conn As New ADODB.Connection
Dim RSProduct As ADODB.Recordset
Sub OpenDB()
Set Conn = New ADODB.Connection
Set RSProduct = New ADODB.Recordset
Conn.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=ConnectServer"
End Sub
Private Sub Form_Load()
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "TBL_PRODUCT"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Here the result :

Download Spurce Code Here

Regards,
BelajarVB.com

Subscribe to receive free email updates:

0 Response to "VB 6.0 - SQL Server Connection"

Post a Comment