如何连接表单1中的数据库并从表单2访问它? [英] How to connect database in form 1 and access it from form 2?

查看:113
本文介绍了如何连接表单1中的数据库并从表单2访问它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮助我。



我创建2表格:F1和F2



我用F1打开ms。使用openfile对话框访问数据库。

我希望像编辑一样访问它。更新。保存。在F2中删除。



我在F1中的代码

Con.Connectionstring = @Provider = Microsoft.Ace.Oledb.12.0;数据源=+ openfiledialog.filename +;坚持安全.........



我在构造函数下的F2中获取了连接流。并给我错误。因为在F2中,变量openfiledialog.filename没有定义。



我尝试过:



我不知道代码。所以我尝试创建类和idont知道代码如何

解决方案

根据ThePhantomUpvoter的建议,

你需要DataAccess Layer。它真的很难帮助如何问题。



你能不能通过现有的申请,这将帮助你

使用WinForms,C#.NET,ADO.NET和MS Access的示例应用程序 [ ^

Please someone help me.

I create 2 form: F1 and F2

I use F1 to open ms. Access database using openfile dialog.
And I want access it like edit. Update. Save. Delete in F2.

My code in F1
Con.Connectionstring = @"Provider=Microsoft.Ace.Oledb.12.0;data source=" + openfiledialog.filename + "; persist security.........

And I took the connection stream in F2 under the constructor. And give me error. Because in F2, variable openfiledialog.filename not definition.

What I have tried:

I dont know the code. So I tried create class and idont know how the code

解决方案

As suggested by ThePhantomUpvoter,
you need DataAccess Layer. its really hard to help on "How To" questions.

Could you please go through existing application, This will help you
Sample application using WinForms, C#.NET, ADO.NET and MS Access[^]


这篇关于如何连接表单1中的数据库并从表单2访问它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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