i have code link this to Update data in mysql through excel Please help me out
i have made some changes in mysql db
I HAVE TAKEN IN MYSQL DB(Column) WMS_ID AS VARCHAR(45) AND A PRIMARY KEY
example:This is my table whos Column look like this i am trying to make this column unique
WMS_ID
WMS10001
WMS10002
WMS10003
WMS10004
WMS10005
WMS10006
i have made some changes in mysql db
I HAVE TAKEN IN MYSQL DB(Column) WMS_ID AS VARCHAR(45) AND A PRIMARY KEY
example:This is my table whos Column look like this i am trying to make this column unique
WMS_ID
WMS10001
WMS10002
WMS10003
WMS10004
WMS10005
WMS10006
Code:
Dim dbconn As New ADODB.Connection Dim stDB, strConn
Dim totColumns, totRows, i, j, BMS_id, UpdateprBatchName
Dim prBatchName, prTableQry, inTableQry, prTableQry1, dbQry
Dim rs As New ADODB.Recordset
'Path to the database.
stDB = "mysql32"
'Create the connectionstring.
strConn = "Driver=MySQL ODBC 5.2 Unicode Driver;" _
& "Data Source=" & stDB & ";"
Sheet1.Activate
'prBatchName = "tblprod_agr_007"
totColumns = ActiveSheet.Cells(2, 1).CurrentRegion.Columns.Count
totRows = ActiveSheet.Cells(3, 1).CurrentRegion.Rows.Count
'prBatchName = ActiveSheet.Cells(3, totColumns + 1).Values
dbconn.Open strConn
rs.CursorLocation = adUseServer
rs.Open "select * from " & InputBox("Update Data"), dbconn, adOpenStatic,
adLockOptimistic
For j = 3 To totRows + 1
WMS_id = ActiveSheet.Cells(j, 1)
rs.Find "WMS_ID=" & BMS_id
For i = 2 To totColumns
rs(ActiveSheet.Cells(2, i).Value) = ActiveSheet.Cells(j, i)
Next
rs.Update
Next
rs.Close
dbconn.Close
MsgBox "Data updated sucessfully"
End Sub
Last edited: