sql server vb net ado odd record update [英] sql server vb net ado odd record update

查看:83
本文介绍了sql server vb net ado odd record update的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个dbgrid连接到一个带有bindingsource的sql server表,奇怪的是当我只给第一个字段(nvarchar)赋值并且更新它时擦除了值,并留下一个空记录,当我向第一个字段和第二个或更多字段(所有其他字段都是日期类型)提供vaqlue时,它接受并记录正确。

更新按钮代码

 私有  Sub  ToolStripButton1_Click( ByVal 发​​件人作为系统。对象 ByVal  e  As  System.EventArgs)句柄 ToolStripButton1.Click 
Me .CarBindingSource3.EndEdit()
如果 DataSet11.HasChanges 然后
尝试
SqlDataAdapter1.Update(DataSet11, car
DataSet11.AcceptChanges()
Catch eUpdate As System.Exception
投掷 eUpdate
结束 < span class =code-keyword>尝试

结束 如果
结束 Sub



所有字段均为设置允许sql和table中的空值有PK。

有什么想法吗?



谢谢

解决方案

Hello,
I have a dbgrid connected to an sql server table with a bindingsource, the odd thing is that when I give value only to the first field (nvarchar) and do update it erases the value and leaves an empty record, when I give vaqlue to the first field and to the second or more (all other fields are date type) it accepts and record is proper.
code of update button

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Me.CarBindingSource3.EndEdit()
        If DataSet11.HasChanges Then
            Try
                SqlDataAdapter1.Update(DataSet11, "car")
                DataSet11.AcceptChanges()
            Catch eUpdate As System.Exception
                Throw eUpdate
            End Try
        End If
    End Sub


All fields are set to allow nulls in sql and table has PK.
Any idea?

Thank you

解决方案

这篇关于sql server vb net ado odd record update的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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