INSERT INTO sql很难 [英] Difficulty with INSERT INTO sql

查看:75
本文介绍了INSERT INTO sql很难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定在我的错误处理程序中添加一个语句,它会将任何错误发送到我以后可以查看的表中。但是当代码到达其中一个语句时,我一直收到随机错误。


这是错误处理程序中的一个语句...

I decided to put a statement in my error handlers that would send any errors to a table that I could look at later. But I keep getting random errors when the code gets to one of these statements.

Here is one of the statements in the error handler...

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号

推荐答案

脑海中浮现出两个想法:
Two ideas spring to mind :
  1. 如果你不喜欢在代码进入错误处理程序之前,没有退出Sub 行,然后代码可以通过而不会实际发生任何错误。
  2. VBIDE在 T ools / O ption下有一个设置s / 常规 / 错误捕获

    如果您将此设置为 B 恢复所有错误然后永远不会调用您的错误处理。其他两个都应该适合你。我倾向于在类模块中使用 B r eak,因为它处理普通代码和类代码,但打破未处理的 E 如果你没有在Classes上做任何工作,那么rrors 应该也能正常工作。
  1. If you don''t have an Exit Sub line before the code drops into the error handler then the code can drop through without actually hitting any error.
  2. In the VBIDE there is a setting under Tools / Options / General / Error Trapping.
    If you have this set to Break on All Errors then your error handling will never be invoked. Either of the other two should suit you. I tend to use Break in Class Module as that handles ordinary code as well as Class code, but Break on Unhandled Errors should work just as well if you aren''t doing any work on Classes.


BHo15,

令我困惑的是你的错误声明: 查询表达式中的语法错误(缺少运算符)查询表达式中的日期语法错误''EntryDate#3/18/2018#AND#至于''


根据您的预期SQL语句,我在#3/18之间看不到短语 EntryDate / 2018#AND #To Date 。所以,有些东西告诉我你的错误被抛到其他地方,而不是在你的错误处理期间(我为你试图将错误处理放入你的所有代码而感到自豪)。 ; - )
BHo15,

What is confusing to me is your error Statement: Syntax error (missing operator) in query expression Syntax error in date in query expression ''EntryDate Between #3/18/2018# AND #To Date''.

Based upon your intended SQL statement, I do not see the phrase EntryDate Between #3/18/2018# AND #To Date. So, something tells me that your error is being thrown elsewhere, and not during your Error Handling (which I am proud of you for trying to put Error Handling into all your code). ;-)


首先关闭NeoPa ......我确实有Exit Sub。我检查了错误陷阱的设置,并将其设置为Break on Unhandled Errors。


Twinnyfo ......我完全同意。那令我困惑的是。似乎弹出的错误是使用错误处理程序的初始错误,即使它在错误处理程序的INSERT INTO语句中停止。没有意义。


谢谢你们两位!
First off NeoPa... I do have Exit Sub in place. And I checked the setting for Error Trapping, and it was set to Break on Unhandled Errors.

Twinnyfo... I totally agree. That is what is baffling me. It seems to be that the error that is popping up is the initial error that engaged the Error Handler, even though it is stopping on the INSERT INTO statement of the Error Handler. Makes no sense.

Thank so to you both!


这篇关于INSERT INTO sql很难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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