1
このケースではヘルプが必要です。 ExcelからSQL Serverにテーブルをインポートする必要があります。DATE型の2つの列があります。マクロを実行するとExcelからSQL Serverにインポートするときの日付データ型変換エラー
問題があり、次のメッセージが表示さ
変換は、文字列から
を日付/時刻の会話時にExcelの表は、この形式で日付が含まれていませんでしたdd/mm/YYYY
、SQL Server列のデータ型はDATE
です。この問題を解決するために私は助けが必要ですか?ご協力ありがとうございました。
'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