Saturday 1 October 2016

Vb6 Script for Database connection

Read data from MS ACCESS Database

Free code, example code, sample code
Step 1: Open new VB6 project.
Step 2: Select Standard EXE
Step 3:

Step 3: Select the following references

Step 4: Create MS ACCESS Database

Step 5: Add text-box and button

Step 5: Paste this VBScript

Private Sub Command1_Click()
Dim strfile As String
Dim Strcon As String
Dim sqlstr As String
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
strfile = "C:\Database.mdb"
Strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strfile & ";"
Set rs = New ADODB.Recordset
cn.Open Strcon
sqlstr = "SELECT * from Temperature_Data"
rs.Open sqlstr, cn, adOpenDynamic, adLockOptimistic
Text1.Text = rs!Present_Value
Text2.Text = rs!Set_Point
rs.Close
cn.Close
End Sub

Enjoy! Now you can able to read present value and setpoint from database



No comments:

Post a Comment