直到用户输入时出现的数据应为空白 [英] Data appearing when should be blank till user inputs

查看:60
本文介绍了直到用户输入时出现的数据应为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

再次返回....

我有一个VB.NET前端,该前端使用Jet 4.0链接到Access数据库表(2003)

数据就在那里,并且可以正常工作,
问题是,当我单击添加新记录"时,任何具有DATE输入的字段都插入了当前日期. (同样,复选框字段显示为全部填充).
这些字段需要留空,直到用户输入日期为止,因为其中一些与将来的交货日期有关.

很抱歉,如果这不是技术性的,不确定如何描述,但我认为基本上是这样.

问题是;

在用户输入日期之前,它应该只是NULL(访问期限)字段时,如何停止DATE数据分配?


这是代码工作室在我使用向导thingy时自动创建的:-

代码:


私有 bindingNavigatorSaveItem_Click( ByVal 发件人 As System.Object, ByVal e As System.EventArgs)处理bindingNavigatorSaveItem.单击
      如果 .然后验证然后
             .Customer_DataBindingSource.EndEdit()
           ;   .Customer_DataTableAdapter.Update( .DataSet1.Customer_Data)
    ;     E lse
            System.Windows.Forms.MessageBox.Show( Me 发生验证错误." 保存" ,System.Windows.Forms.MessageBoxButtons.好的,System.Windows.Forms.MessageBoxIcon.Warning)
        End 结束

Private Sub bindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindingNavigatorSaveItem.Click
        If Me.Validate Then
            Me.Customer_DataBindingSource.EndEdit()
            Me.Customer_DataTableAdapter.Update(Me.DataSet1.Customer_Data)
        Else
            System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
        End If

    End Sub

推荐答案

大家好,

我只是一直在研究这个问题,并且发现了(我认为)我的问题出在哪里.

我查看了有问题的数据字段的默认值.
它们已经设置为Null

它自己实际说的值是       默认值:< DBNull>
                NullValule:(抛出异常)
我以前从未见过NullValue,这可能是导致问题的原因,并且Throw异常是什么意思?
我的书没有告诉我,老实说,我在互联网上搜索的内容超出了我的范围.


除上述内容外,我看不到任何会影响这些字段的内容.
我什至回到了我的访问数据集,并且它们的值也设置为Null.

这让我感到困惑.

Max


[edit]

进一步研究,我发现我可以更改Throw Exception字段. (我现在认为这是问题的根源)
但是,当我尝试此操作时,我收到以下消息
属性值无效"
",对于未定义为System的列.字符串,唯一有效的值是(抛出异常)."
谁能告诉我这是什么意思,如果可以解决这个问题,以便我可以将Null字段放到适当的位置.
Hi guys,

Just been looking into this abit more, and have found ( I think ) Where my problem lies.

I have looked at the default value of the data fields in question.
They are already set to Null

The value it self actually says         Default Value: <DBNull>
                NullValule: (Throw exception)

I have never seen the NullValue before, could this be causing the problem, and what does Throw exception mean ?
My book doesn`t tell me, and my internet searches come up with stuff that is just beyond my to be honest.


Apart from the above, I cant see anything that would effect these fields.
I have even gone back into my access dataset, and their values are also set to Null.

Thas has me baffled.

Max


[edit]

Looking further into this, I have found that I can change the Throw Exception Field. ( Which I now think is the culprit of my problem )
However, when I try this I get the floowing message
"Propert Value is not Valids"
"For columns not defined as System.String, the only valid value is (Throw exception)."
Could anyone tell me what this means please, and if there is away round this so that I can get the Null fields in place.


这篇关于直到用户输入时出现的数据应为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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