Connection Visual Basic 6.0 With MySql Database.
First step you must download MySql ODBC 5.15, and istall it. after it insert ADO Data Control Component in to your project.
Then create a form , add a adodc component and a command button, see picture below.
Write this code to command button procedure.
Private Sub Command1_Click()
Dim myConnection As New ADODB.Connection
Set myConnection = New ADODB.Connection
myConnection.ConnectionString = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;Data Source=yourdatasourcename"
myConnection.Open
If myConnection.State = adStateOpen Then
MsgBox "Connection Success"
Else
MsgBox "Connection Failed"
End If
myConnection.Close
Dim myConnection As New ADODB.Connection
Set myConnection = New ADODB.Connection
myConnection.ConnectionString = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;Data Source=yourdatasourcename"
myConnection.Open
If myConnection.State = adStateOpen Then
MsgBox "Connection Success"
Else
MsgBox "Connection Failed"
End If
myConnection.Close
End Sub
For any question comment this post..!
0 comments:
Post a Comment