Hi, I have easy one here, but can't get it done, I want to update MySQL DB via Visual basic based on cell value.
Table in MySQL has column ID and column Value, I would like to update that value based on A1 cell value in Sheet1. So far I have this code, but I receive an error message. Can you guide me where I did wrong or how to update it in other way.
Thank you.
Table in MySQL has column ID and column Value, I would like to update that value based on A1 cell value in Sheet1. So far I have this code, but I receive an error message. Can you guide me where I did wrong or how to update it in other way.
Thank you.
Code:
Private Sub CommandButton1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
strCon = "Driver={MySQL ODBC 5.1 Driver};SERVER=doks;DATABASE=teke_brojeva;UID=***;PWD=***"
Set cn = CreateObject("ADODB.Connection")
cn.Open strCon
Set rs = CreateObject("adodb.recordset")
rs.Open "UPDATE ugovori_dt SET br_ugovora='" & (Cells(1, 1).Values) & "'", cn
rs.Close
End Sub