1
我需要此案例的帮助。我需要从Excel导入表格到SQL Server,我有两列DATE类型。从Excel导入到SQL Server时的日期数据类型转换错误
问题是,当运行宏,显示以下信息从字符串
在Excel表中包含的日期这种格式交谈日期和/或时间时
转换失败
dd/mm/YYYY
和SQL Server列的数据类型为DATE
。请帮我解决这个问题。感谢您的支持。连接的代码在VBA
'Create Conection for MySQL Database in AR_TELCEL Dim conn As New ADODB.Connection conn.CommandTimeout = 0 'Define Data Types to Cells for Upload a SQL Database Dim iRowNo As Long Dim CUST_ID As Long, DOC_TYPE As String, BILL_DOC As Long, REFERENCE As String, STATUS_PAYMENT As String, INV_CON As String, OSALES_FOUR As String, INV_REF As String, DOC_NUM As Long, GL As Long, DOC_DATE As Date, DUE_DATE As Date, DOC_CURRENCY As String, DOC_AMNT As Currency, LOC_AMNT As Currency, PAY_TERM As String, POST_K As String, LINE_N As Long With Sheets("I. One Report Sap") '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 'Connect with MSSQL PCC AR_TELCEL Database '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ conn.Open "Provider=SQLOLEDB;Data Source=146.250.36.68,1433;Initial Catalog=AR_TELCEL;User Id=user;Password=Password;" 'Omitimos la linea de encabezados iRowNo = 10 'Loop until empty cell in CustomerId Do Until .Cells(iRowNo, 1) = "" ACCOUNT = .Cells(iRowNo, 1) DOC_TYPE = .Cells(iRowNo, 2) BILL_DOC = .Cells(iRowNo, 3) REFERENCE = .Cells(iRowNo, 4) STATUS_PAYMENT = .Cells(iRowNo, 5) INV_CON = .Cells(iRowNo, 6) ORDER_SALES = .Cells(iRowNo, 7) INV_REF = .Cells(iRowNo, 8) DOC_NUM = .Cells(iRowNo, 9) GL = .Cells(iRowNo, 10) DOC_DATE = .Cells(iRowNo, 11) DUE_DATE = .Cells(iRowNo, 12) DOC_CURRENCY = .Cells(iRowNo, 13) DOC_AMNT = .Cells(iRowNo, 14) LOC_AMNT = .Cells(iRowNo, 15) PAY_TERM = .Cells(iRowNo, 16) POST_K = .Cells(iRowNo, 17) LINE_N = .Cells(iRowNo, 18)
这是你真正的'sa'密码吗? – cha
请勿使用'sa'用户。期。 –
尝试使用DATEFORMAT DMY; – ZLK