昏暗截断一个字符串,或观看窗口截断? [英] Dim truncating a string, or watch window truncating?

查看:60
本文介绍了昏暗截断一个字符串,或观看窗口截断?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个严肃的Twilight Zone时刻:


在下面的代码中,我正在构建一个SQL命令到一个字符串变量,在我的顶部声明代码。

然后,我连接到数据库并尝试执行SQL代码。


这里是相应的片段:

展开 | 选择 | Wrap | 行号

解决方案

嗨geolemon。我不知道手表问题,在我看来这不是很重要。我认为这是一条死胡同。


出现更实质性的难题 - 参数问题 - 因为除非我误认为你的字段名称,否则你似乎是指用户数据输入参数,[DNP?],并且执行不能简单地停止并询问用户参数的值。在这种情况下,错误消息是明确的,并指向正确的方向。数据库引擎将反对在此类操作查询中查找没有指定值的参数。使用Execute或RunSQL运行的查询不一定像在访问查询编辑器窗口中测试此类查询时所期望的那样,确实会要求您提供参数的值。

我认为您需要在运行INSERT之前从用户获取所需的值。这也将允许您取消效率低下的SWITCH语句并构建适当版本的SQL语句,以涵盖列出的真实和错误状态组合。


-Stewart

你好GeoLemon。


你的问题提出了一些有趣的观点,我会在找到答案时回答。


首先,如果使用正确的引号字符,您在VBA情况下理解SQL中发生的事情的能力会显着增加(参见引号('')和双引号(") - 何时何地使用它们


第二个容易的是,是的,监视窗口限制为<255个字符。我假设实际数字是250,因为你发现它在那里被截断。不过不用担心,因为VBA字符串会达到(大约)64K字节。要从调试器(立即窗格)中查看实际数据类型Ctrl-G并键入? strProc" ;.这会将内容转储到相同的立即窗格中。


我已经对您的字符串进行了一些手动解析,包括为了清晰起见重新格式化白色空间并在适当的时候切换引号字符以下内容:

展开 | 选择 | Wrap | 行号


I''m having a seriously Twilight Zone moment:

In the code below, I''m building a SQL command into a string variable, declared at the top of my code.
Then, I connect to the database and try to execute the SQL code.

Here''s the corresponding snippets:

Expand|Select|Wrap|Line Numbers

解决方案

Hi geolemon. Don''t know about the watch problem, which in my view is not likely to be significant. I think it''s a blind alley here.

The more substantive difficulty - the parameter issue - arises because unless I am mistaken about your field names you appear to be referring to a user-data-entry parameter, [DNP?], and Execute cannot simply stop and ask the user for the value of the parameter. In circumstances like this the error message is explicit and is pointing you in the right direction. The database engine will object to finding a parameter without an assigned value in an action query like this. Queries run by the use of Execute or RunSQL do not necessarily behave quite as you might expect from testing such a query in the Access Query Editor window, where you will indeed be asked for the value of the parameter.

I think you need to get the required value from the user before you run the INSERT. This will also allow you to do away with the inefficient SWITCH statements and build appropriate versions of your SQL statement to cover the true and false state combinations which are listed.

-Stewart


Hi GeoLemon.

Your question raises some interesting points which I will respond to as I find answers.

Firstly, your ability to understand what is going on in a SQL within VBA situation is markedly increased if the proper quote characters are used (See Quotes ('') and Double-Quotes (") - Where and When to use them).

Second easy one is that yes, the watch window is limited to <255 chars. I assume the actual figure is 250 as you''ve found it to truncate there. Worry not though, as VBA strings go to (circa) 64K bytes. To see the actual data type Ctrl-G from the debugger (Immediate Pane) and type in "? strProc". This will dump the contents out into the same Immediate Pane.


I have done some manual parsing of your string, including reformatting the white-space for clarity and switching the quote chars where appropriate and came up with the following :

Expand|Select|Wrap|Line Numbers


这篇关于昏暗截断一个字符串,或观看窗口截断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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