sendex'##'中更新错误的问题 [英] problem in updating error in sentex '# # '

查看:82
本文介绍了sendex'##'中更新错误的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我.
我想从这些文本框中插入日期.我在使用访问表单和访问数据库2003的sendex''##''消息中遇到错误.
这是我的代码:

Please help me.
I want to insert date from these textboxes. I am getting error in sentex ''# #'' message using access form and access database 2003.
Here is my code:

Dim strconn As String
Dim myconn As New ADODB.Connection
Dim myrecordset As New ADODB.recordset
Dim sql1 As String
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\downloads\db2.mdb;Persist Security Info=false"
Set myconn = New ADODB.Connection
myconn.Open (strconn)
sql1 = "update Table1 set [dol1]=#" & Format(txtl1.Value, "dd-mmm-yy") & "#,[dol2]=#" & Format(txtl2.Value, "dd-mmm-yy") & "#, [dol3]=#" & Format(txtl3.Value, "dd-mmm-yy") & "#   WHERE cid='" & txtcid.Value & "'"
'myconn.ConnectionTimeout = 60
'Set myrecordset = New ADODB.recordset
myconn.Execute (sql1)


请帮忙.在此先谢谢您.


Please help. Thanks in advance.

推荐答案

在查询中尝试使用''"代替#".
AFAIK,#是Access中的通配符.
Try using "''" instead of "#" in your query.
AFAIK, # is a wild care character in Access.


编写代码的方式必须确保所有三个文本框都具有有效的日期值.如果我没有记错的话,某些文本框将不包含日期值.这就是为什么Format(txtl1.Value, "dd-mmm-yy")生成空白字符串,结果将 #" & Format(txtl1.Value, "dd-mmm-yy") & "#转换为字符串# #的原因. #中的文本必须是Access DB中的日期值.在您的sql1 var中检查查询,您将看到问题.
The way you have written the code you have to ensure all three textboxes has some valid date value. If i am not mistaking then some of textbox does not contain a date value. That’s why Format(txtl1.Value, "dd-mmm-yy") is producing a blank string resulting #" & Format(txtl1.Value, "dd-mmm-yy") & "# to a string "# #". A text within # must be a date value in access DB. Check the query in your sql1 var you will see the problem.


这篇关于sendex'##'中更新错误的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆