Question

I have a VB6 project where would be adding data to database and querying it later. I have a method updateDB for updating the database with fields:

Function UpdateDB()
Dim DBCon As ADODB.Connection
Dim DBCmd As ADODB.Command
Dim dbrecset As ADODB.Recordset


Set DBCon = New ADODB.Connection
DBCon.CursorLocation = adUseClient
DBCon.ConnectionString = "Driver = {MySQL ODBC 3.51 Driver}; Server =myHosting; Port = 3306;Database=myDB;UID=myUID;PWD=12345;Option=16427;"

DBCon.Open
Set dbrecset = New ADODB.Recordset
With DBCmd
.ActiveConnection = DBCon
.CommandText = "UPDATE vbtest SET Name = '" & Text1.Text & "'," _
& "Serial = '" & Text2.Text & "'," _
& "WHERE Key = '" & Text3.Text & "' AND Name IS NULL"
.CommandType = adCmdText
End With

With dbrecset
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open DBCmd
End With

dbrecset.Close
DBCon.Close

End Function

This function gives the following error at run-time.

VBError

EDIT:I have tried it by using versions 3.51/5.1/5.2 of the ODBC drivers

What am I doing wrong? Been stuck around for days now. Please help

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top