“无法识别的数据库格式”每天发生一次错误 [英] "Unrecognized database format" error happening once a day

查看:62
本文介绍了“无法识别的数据库格式”每天发生一次错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我目前有一个拆分数据库,我在使用一天后仍然收到此错误。一旦我修复了它,我就创建了一个干净的数据库,从之前的备份导入了表,一切都没有问题,直到第二天它再次被破坏。起初我觉得这是一个糟糕的形式。所以我重建了它。


你可以查看这个表格上的代码吗?


这个表格的作用是从终端插入数据 - 用户(在桌面上有FE)用于渠道问题。如果在同一市场中有3个频道号实例,它将向管理员发送一封电子邮件,通知可能出现的问题。市场上同一频道的任何更多实例都会弹出一个消息,说我们有足够的问题并关闭。


在同一表格中还有一个明确的频道中断 ;按钮,一旦市场中的所述渠道问题得到解决就被使用,所以如果该市场中存在该渠道的另一个实例,那么最终用户可以再次提交它(因为它可能是另一个问题,与已清除无关) ;一)


在该表格的代码中,我是不是优雅地退出应用程序?我使用LDB Viewer,当应用程序退出时,它表示我已退出应用程序,但我将DB留在可能的可疑状态。国家...无论如何要避免这种情况?


以下是该表格的代码......

----------- -------------------------------------------------

展开 | 选择 | Wrap | 行号

解决方案

Clarence,


我会做的一件事绝对做的是测试我的代码并在测试过程中打开警告,看看你得到了什么样的警告:


其次,我快速粗略了看看你的代码并看到两件看起来有问题的东西。


1.你使用LossFocus事件进行验证。通常,验证是在Form_BeforeUpdate事件中完成的,该事件是在保存任何数据之前发生的事件。使用lostFocus事件并不能保证您想要填充的控件将被填充.....>>>>>>简单地说,如果控件永远不会获得焦点,则lostfocus事件将永远不会触发对于该控件,。以及如果某些控件未填充则会导致错误....这可能是损坏的来源<<<<<<<<<<此外,可以出于正当理由取消更新前事件....就像此人在进入之前必须查找某些信息一样。请逐步查看此链接howTo使用表单的beforeUpdate事件进行数据验证。

http://www.databasedev.co.uk/validate_textbox.html


2.第二件看起来可能有问题的是这一行:


ClearChannel =" UPDATE TBLMaster SET TBLMaster.FldCleared =''yes''"


一般是/否字段被声明为布尔数据类型;如果FldCleared在表中定义为boolean,则设置等于​​字符串Yes。不正确...应该设置为布尔值True或False。因此,您的更新语句可能导致损坏。


希望这会有所帮助。


小狗,


如果我删除了LostFocus代码来自那里,只是在btnCheckFinish进行验证......会更好吗?


我使用你建议的vaidation代码遇到的问题是我做完之后btnCheckFinish,如果字段中没有数据我正在验证,它会弹出需要的数据。框,然后给我一个msg,上面写着没有当前记录并让我回到表格。我怎样才能得到它给我验证信息的地方,把焦点放回到表格上并且不再继续btnCheckFinish子。


谢谢,

Clarence



Clarence,


一件事我肯定会测试我的代码,在测试过程中打开警告,看看你得到了什么样的警告:


其次,我快速粗略了看看你的代码并看到两件看起来有问题的东西。


1.你使用LossFocus事件进行验证。通常,验证是在Form_BeforeUpdate事件中完成的,该事件是在保存任何数据之前发生的事件。使用lostFocus事件并不能保证您想要填充的控件将被填充.....>>>>>>简单地说,如果控件永远不会获得焦点,则lostfocus事件将永远不会触发对于该控件,。以及如果某些控件未填充则会导致错误....这可能是损坏的来源<<<<<<<<<<此外,可以出于正当理由取消更新前事件....就像此人在进入之前必须查找某些信息一样。请逐步查看此链接howTo使用表单的beforeUpdate事件进行数据验证。

http://www.databasedev.co.uk/validate_textbox.html


2.第二件看起来可能有问题的是这一行:


ClearChannel =" UPDATE TBLMaster SET TBLMaster.FldCleared =''yes''"


一般是/否字段被声明为布尔数据类型;如果FldCleared在表中定义为boolean,则设置等于​​字符串Yes。不正确...应该设置为布尔值True或False。因此,您的更新语句可能导致损坏。


希望这会有所帮助。


Clarence,

我有个更好的主意。创建一个Form_BeforeUpdate proc,调用(并重新执行)lostFocus subs(如下所示)。这样您就可以保留lostFocus事件,除了对错误消息的修改,这也将在下面显示。以这种方式执行Form_BeforeUpdate事件将作为任何未通过lostFocus事件过程捕获和/或纠正的验证错误的安全网,同时捎带已经不再需要更正的更正。


之前的更新将连接lostFocus subs返回的每个验证失败消息,并会告知用户所有剩余错误的单个消息框,每条消息都有自己的错误消息框中的行。如果任何验证返回错误字符串,则返回值将取消更新,并且将阻止用户离开记录。这是一个必要的邪恶,以强制纠正任何关键项目。因此,如果您尝试在lostFocus事件中捕获的缺失信息对于数据库的完整性并不重要,则不要在Form_beforeUpdate proc中为该项调用lostFocus事件。通过这种方式,您将拥有两全其美的优势。


在一般声明部分,为丢失焦点事件中的每条消息调暗一个strMsg:

展开 | 选择 | Wrap | 行号< /跨度>

Hello,

I currently have a split db and I keep getting this error after about a day''s worth of use. Once I''ve repaired it, I have created a clean db, imported the tables from a previous backup and everything works with no issues, until the next day when it gets corrupted again. I thought at first it was a bad form. so I rebuilt it.

Can u look at the code on this form?

What this form does is it inserts data from end-users (who have the FE on their desktops) for channel issues. If there is 3 instances of the channel number in the same market it will send an email to a supvervisor informing of possible issues. Any more instances of that same channel in the market, will pop up a msg saying we have enough issues and close out.

In this same form there is also a "clear channel outage" button, which is used once said channel issue in market has been resolved, so if there is another instance of that channel in that market then the end-user can submit it again (as it maybe another issue, not related to the ''cleared" one)

In the code of that form, am I not exiting the application gracefully? I use LDB Viewer and when the app exits, it says I exited the app but I''m leaving the DB in a possible "suspect" state...anyway to avoid that?

Here is the code for that form...
------------------------------------------------------------

Expand|Select|Wrap|Line Numbers

解决方案

Clarence,

One thing I would definitely do is test my code with the warnings turned on during testing and see just what kinds of warnings you are getting:

Secondly, I took a quick "rough" look at your code and saw two things that look problematic.

1. Your use of the LossFocus event for validation. Generally validation is done in the Form_BeforeUpdate event, which is the event that occurs just before any data is saved. Using the lostFocus event does not guarantee that the controls you want filled will be filled.....>>>>>>simply said, if a control never gets the focus, the lostfocus event will never fire for that control,.and if some of the controls cause an error if they are not filled....that could be a source for corruption<<<<<<< In addition, the before update event can be canceled for legitimate reasons ....like the person has to look up some information before entering. See this link for a step by step "howTo" do data validation using the beforeUpdate event of the Form.

http://www.databasedev.co.uk/validate_textbox.html

2. the second thing that looks potentially problematic is this line:

ClearChannel = "UPDATE TBLMaster SET TBLMaster.FldCleared = ''yes''"

Genrally yes/no fields are declared as a boolean data type; if FldCleared is defined as boolean in your table, then setting equal to the string "Yes" is incorrect...it should be set to Boolean True or False. Consequently, it is possible that your update statement is causing the corruption.


Hope this helps.


Puppy,

If I removed the LostFocus code from there and just do the validation at btnCheckFinish...would that be better??

The issue I run into with using the vaidation code that u are suggesting is that after I do the btnCheckFinish, if no data is present in the field I''m validating, It''ll pop up the "data needed" box and then give me a msg that says "No current record" and puts me back to the form. How can I get it where it gives me the validation message, give focus back to the form and won''t continue the btnCheckFinish sub.

Thanks,

Clarence



Clarence,

One thing I would definitely do is test my code with the warnings turned on during testing and see just what kinds of warnings you are getting:

Secondly, I took a quick "rough" look at your code and saw two things that look problematic.

1. Your use of the LossFocus event for validation. Generally validation is done in the Form_BeforeUpdate event, which is the event that occurs just before any data is saved. Using the lostFocus event does not guarantee that the controls you want filled will be filled.....>>>>>>simply said, if a control never gets the focus, the lostfocus event will never fire for that control,.and if some of the controls cause an error if they are not filled....that could be a source for corruption<<<<<<< In addition, the before update event can be canceled for legitimate reasons ....like the person has to look up some information before entering. See this link for a step by step "howTo" do data validation using the beforeUpdate event of the Form.

http://www.databasedev.co.uk/validate_textbox.html

2. the second thing that looks potentially problematic is this line:

ClearChannel = "UPDATE TBLMaster SET TBLMaster.FldCleared = ''yes''"

Genrally yes/no fields are declared as a boolean data type; if FldCleared is defined as boolean in your table, then setting equal to the string "Yes" is incorrect...it should be set to Boolean True or False. Consequently, it is possible that your update statement is causing the corruption.


Hope this helps.


Clarence,
I have a better idea. Create a Form_BeforeUpdate proc that calls (and re-executes) your lostFocus subs (as shown below). That way you can leave your lostFocus events as they are, except for modifications to the error message, which is also show below. Executing the Form_BeforeUpdate event in this way will act as a safety net for any validation errors not captured and/or corrected via your lostFocus event procedures, while piggybacking on corrections already made that no longer require correction.

The before update will concatenate each of the validation failure messages returned by the lostFocus subs and will advise the user with a single message box for all the remaining errors, with each message having its own row in the message box. The return value will cancel the update if any validation returns an error string and the user will be prevented from leaving the record. This is a necessary evil in order to force correction on any critical items. So, if the missing info that you are trying to trap in the lostFocus events is not critical to the integrity of your database, don?t call the lostFocus event for that item in your Form_beforeUpdate proc. This way you will have the best of both worlds, so to speak.


In the general declarations section, Dim a strMsg for each one of your messages in the lost focus events:

Expand|Select|Wrap|Line Numbers


这篇关于“无法识别的数据库格式”每天发生一次错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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