如何从Form1动态调用Access 2007数据库记录 [英] How to Call Access 2007 db records dynamically from Form1

查看:62
本文介绍了如何从Form1动态调用Access 2007数据库记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生/女士:

我已经在该项目中创建了一个带有几个Forms的C#项目.在一种特定的形式(让我们说Form1)中,我有10个按钮.我还创建了一个Access 2007数据库,并且在该数据库中有一个包含10条记录的表.

现在我的问题是:

是否可以从Form1动态调用这10个数据库记录(但不能一对一地调用).

我的意思是我不想为每个按钮事件创建打开的数据库连接,执行查询等.所以基本上我想要的是:表单中有10个按钮来创建一个sql查询(至少说像数组查询),所以当我单击button1从数据库表中获取rocord1并将displayit进入我的列表视图时,相同用于button2,button3等...

基本上我想要的是,当Form1加载(此表单内有10个按钮)以创建SQL查询时,从数据库中获取那10条记录,而我单击的每个按钮都希望该db记录与相应的按钮匹配并显示该记录在我的列表视图中.


亲切的问候


Agron

Dear Sir/Madam

I have created a C# Project with couple of Forms inside this project. In one particular form (lets say Form1) I have 10 Buttons. I also created a Access 2007 DataBase and inside this database I have a table with 10 records.

Now my question is:

Is there a possibility to call these 10 database records dynamically from Form1 (but not one-by-one).

What I mean is I dont want to create for every button event an opening db conn, exec query, and so on. So basically what I want is: the 10 buttons that I have in my form to create one sql query (lest say like an array query) so when I click button1 to get the rocord1 from db table and displayit in to my list view, same for button2, button3 and so on...

Basically what I want is, when Form1 Loads (where inside this form are 10 buttons) to create an SQL Query, get those 10 records from database, and each button I click I want that db record to match the corresponding button and display that record on my list view.


Kind Regards


Agron

推荐答案

您尝试过什么吗?

如果仅使用select * from myTable order by button_id之类的sql语句选择记录,则将获得包含所有记录的记录集.您可以简单地获取所需的行,因为记录集中所有行均可用.

http://www.sqlselect.org/cs-sql-select-access.html [ ^ ]

祝你好运!
Have you tried anything?

If you would simply select the records with an sql statement like select * from myTable order by button_id then you will get a recordset with all the records. You could simply get the row you want because all the rows are available in the recordset.

http://www.sqlselect.org/cs-sql-select-access.html[^]

Good luck!


这篇关于如何从Form1动态调用Access 2007数据库记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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