gpt4 book ai didi

mysql - VB 导出访问 Mysql 货币格式失败

转载 作者:行者123 更新时间:2023-11-29 22:14:35 25 4
gpt4 key购买 nike

Access 2003 上的以下 VBA 脚本将所有表和数据导出到 MySQL。除了货币数据之外,一切正常,它们被转换为整数而不是 float 。 float 已正确导出。

在 Access 2003 中

price : 1,22 € (currency format)
VAT : 1,115 (float)

在mysql中变成:

price : 1
VAT : 1.115

这是脚本:

Option Compare Database

Private Sub Détail_Click()

End Sub

Private Sub export_mysql_Click()
On Error GoTo Err_export_mysql_Click

Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC"
'sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
sCnxnStr = "ODBC;DSN=exporteau;UID=exporteau;PWD=xxxxxxxxxxx" 'Create the connection string
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef

MsgBox "Exportation terminée"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls

Exit_export_mysql_Click:
Exit Sub

Err_export_mysql_Click:
MsgBox Err.Description
Resume Exit_export_mysql_Click

End Sub

Private Sub export_mysql_DblClick(Cancel As Integer)

End Sub

最佳答案

MS Access 2002 使用系统区域货币设置。

一旦用设置为分隔小数。而不是我就得到了我的数字。

关于mysql - VB 导出访问 Mysql 货币格式失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31313200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com