如何在不使用主键的情况下删除数据行VB.net [英] how to delete rows of data without using the primary key VB.net

查看:56
本文介绍了如何在不使用主键的情况下删除数据行VB.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用主键VB.net的情况下删除数据行
我正在使用Access 2003& VB 2005

how to delete rows of data without using the primary key VB.net
I am using Access 2003 & VB 2005

Private Sub BtnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDel.Click
Dim dt As New DataTable
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        Dim da As New OleDbDataAdapter

        con.Open()
        da = New OleDbDataAdapter("Select * from Part", con)
        da.Fill(dt)

        dt.Rows(0).BeginEdit()
        dt.Rows(0).Delete()
        dt.Rows(0).EndEdit()

        Dim cb As New OleDbCommandBuilder(da)

        da.Update(dt)

        DataGridView1.DataSource = dt.DefaultView()


        con.Close()
End Sub



我尝试调试和错误结果对于不返回任何键列信息的SelectCommand,不支持DeleteCommand的动态SQL生成"

我知道主键中的问题,但我不想使用主键.
我该怎么办?...
感谢



I try to debug and error results "Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information"

I know the problem in the primary key but I do not want to use the primary key.
what should i do?...
Thanks

推荐答案

在数据库中使用主键有很多好处.对该主题进行的少量研究将帮助您了解为什么要使用它们.没有理由不使用它们.
There are many benefits to using primary keys in a database. A liitle research on the subject will help you to understand why you should be using them. There is no reason to not use them.


这篇关于如何在不使用主键的情况下删除数据行VB.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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