问题描述
我编写了一个插入查询,该查询将datetime和其他列一起插入.除以下情况外,它适用于所有位置我的德国客户登录并运行应用程序,该应用程序给他以下错误.我已经将datevalue格式化为yyyy-mm-dd文化独立.MS Access数据库存储在美国的服务器中.德国客户正在从德国运行应用程序.
I have written an insert query which inserts datetime along with other columns. It works fine for all locations except whenmy German client logs in and runs the application it gives him below error. I have formatted the datevalue to yyyy-mm-dd to make culture independent.MS access database is stored in a server in US.German client is running application from Germany.
strDateSubmit = dtpDateSub.Value.ToString("yyyy-MM-dd")
strSaveOSTR = "INSERT INTO " & strOSTR & " ([OSTR #],[OSTR Type],[# of Samples],[RA#],[Customer],[SKF #],[Test Description]," & _
"[TestLength],[TestUnit],[TestLengthDays],[Requestor],[Date Submitted],[Seals Avail],[Fixtures Available],[Peripherals Avail],[PO Avail]," & _
"[Machine Type],[Hours to Process],[Location],[Current Status],[ErrorsPresent],[ContaminType]" & SampleREcvd1 & ", [Emp_ID],[Industry])" & _
" Values ( '" & strOSTRNum & "', '" & cmbOSTRTypes.Text & "', " & intSamples & ", '" & strRA & "', '" & strCustomer & "', '" & strSKFNum & _
"', '" & strTestDescr & "', " & intTestLength & ", '" & strTestUnits & "', '" & txtTestLDays.Text & "', '" & strRequestor & "', #" & strDateSubmit & "#, '" & strSealAvail & _
"', '" & strFixtAvail & "', '" & strPheriAvail & "', '" & strPOAvail & "', '" & strMachineClass & "', " & intHrstoProc & ",'" & g_objProp.Location & _
"', '" & strStatus & "', '" & ErrorsPresent & "', '" & ContaminationType & "'" & SampleREcvd2 & ", '" & emp_id & "', '" & Industry & "')"
推荐答案
您可能需要更严格的日期表达式字符串格式:
You may need a more strict format of the date expression string:
strDateSubmit = dtpDateSub.Value.ToString("yyyy'/'MM'/'dd")
这将始终返回类似"2016/02/01"
的日期(没有点或破折号),并且将在此处正确连接:
This will always return a date like "2016/02/01"
(no dots or dashes), and it will concatenate correctly here:
"', #" & strDateSubmit & "#, '"
如您所愿.
这篇关于插入MS访问vb.net期间德语窗口中的日期异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!