数据库编辑问题 [英] Database editing issue

查看:71
本文介绍了数据库编辑问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候。

通过一些按钮和下面的代码编辑.accdb文件很简单+在VS 2013中将文件作为数据源导入

Editing a .accdb file is easy via some buttons and below codes + importing the file as data source in VS 2013

Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
        Table1BindingSource.AddNew()
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Try

            Table1BindingSource.EndEdit()

            Table1TableAdapter.Update(Database_productsDataSet.Table1)
            MsgBox("saved!")
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try



    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        Table1BindingSource.RemoveCurrent()
    End Sub

但如果我想做一个用户眉头的应用程序一个.accdb文件和应用程序执行与上面相同的操作 使用相同的按钮编辑和保存.accdb文件。  ?

But what If I want to make an application in which user browses one .accdb file and application does the same thing like above  with the same buttons in order to edit and save the .accdb file.  ?

提前致谢

推荐答案

不完全确定您的要求,但可以告诉您,使用TableAdapter方法访问数据库表时,您只能使用符合强类型的数据库通过TableAdapter / DataSet / BindingSource生成并可用的类。

Not exactly sure what you are asking but can tell you that when using TableAdapter method to access database tables you can only work with databases that met the strong type classes that were generated and available via the TableAdapter/DataSet/BindingSource.

因此,假设您为具有Id和CompanyName的客户表创建了上述内容,然后尝试使用customer表读取另一个访问数据库带有id和名字,不会飞。

So let's say you created the above for a customer table with Id and CompanyName then try to read another access database with customer table with id and name, that would not fly.


这篇关于数据库编辑问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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