PHP的MySQL数据库的更新
在MySQL数据库更新现有的数据很容易通过使用这个VBA宏代码。许多正在使用的方法时,在PHP和MySQL开发网站的工作。
解释 VBA宏代码这是一个效果欠佳的更新优化MySQL数据库。你需要一个连接器,用于下载最新版本mysql.com的ODBC Excel文件吃了这个网页或复制和粘贴代码直接的底部。在文件中有一些数据,根据需要添加到您的设置的MySQL数据库和连接。在数据填充并添加您要更新需要个行业。推动巴特姆,你将更新您的MySQL数据库中的现有数据。 你必须启用Microsoft ActiveX数据对象某某图书馆,以执行VBA宏代码。
码Sub UpdateMySQLDatabasePHP()
' For detailed description visit http://www.vbaexcel.eu/ Dim Database_Name As String Dim User_ID As String Dim Password As String Dim Cn As ADODB.Connection Dim Server_Name As String Dim SQLStr As String Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset
User_ID = Range("h1").Value 'i d user or username Password = Range("e3").Value ' Password Server_Name = Range("e4").Value ' IP number or servername Database_Name = Range("e1").Value ' Name of database Tabellen = Range("e2").Value ' Name of table to write to
rad = 0 While Range("a6").Offset(rad, 0).Value <> tom TextStrang = tom kolumn = 0 While Range("A5").Offset(0, kolumn).Value <> tom If kolumn = 0 Then TextStrang = TextStrang & Cells(5, 1) & " = '" & Cells(6 + rad, 1) If kolumn <> 0 Then TextStrang = TextStrang & "', " & Cells(5, 1 + kolumn) & " = '" & Cells(6 + rad, 1 + kolumn) kolumn = kolumn + 1 Wend TextStrang = TextStrang & "'" SQLStr = "UPDATE " & Tabellen & " SET " & TextStrang & "WHERE " & Cells(5, 1) & " = '" & Cells(6 + rad, 1) & "'" Set Cn = New ADODB.Connection Cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=" & Server_Name & ";Database=" & Database_Name & _ ";Uid=" & User_ID & ";Pwd=" & Password & ";" Cn.Execute SQLStr rad = rad + 1 Wend Set rs = Nothing Cn.Close Set Cn = Nothing
End Sub
下载Excel文件!更新- MySQL的数据库,PHP.xls |