从Access数据库读取文本和数字 [英] Reading Text and Number from Access Database

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

问题描述

你好.

我有一个简单"的问题.

注意-实际上这是Delphi所需要的,但是我没关系,它是C#还是Delphi ButtonClick.只需要代码.但是如果得到答案,由于应用程序仍处于开始阶段,我可能会切换到C#.

这是我第一次尝试数据库编程.无论如何,我迫切需要这个.
我正在构建一个应用程序.我已经准备好一切,我只需要以下内容.如何:

当我按下按钮时,它会从mdb/accdb数据库读取文本或数字吗?

表单有很多按钮,我需要:

1.按下按钮1:3 dbEdit字段更改
2.按下按钮2:相同的dbEdit字段更改为与mdb文件不同的值.
3,与其他按钮相同.只需从适当的ID中读取值即可.

我只是不知道如何访问mdb文件中的值.我尝试了所有可以在网上找到的东西.没有按钮.都与Grids和类似物一起使用.

还有任何帮助:

数据库名称:Enigma.mdb
表格:EnigmaTable
栏位1:ID
栏位2:EngineLevel
Field3:EngineBase
栏位4:EngineName

Hello.

I have a "simple" question.

NOTE - This is needed for Delphi actually but I it doesn''t matter either is it a C# or Delphi ButtonClick. Just need the code. But if I get an answer, I might switch to C# since the application is still at beginning.

This is my first try at database programming. Anyway I need this urgently.
I am building an application. I have everything ready, I just need the following. How to:

When I press a button, it reads a Text or Numbers from mdb/accdb database?

Form has many buttons and I need to:

1. Press button 1: 3 dbEdit fields change
2. Press button 2: same dbEdit fields change with different values from mdb file.
3, Same for other buttons. Just read values from proper ID.

I just don''t know how to access the values in the mdb file. I tried everything possible I could find on the net. Nothing with BUTTON. all go with Grids and similar.

And also if any help:

Database Name: Enigma.mdb
Table: EnigmaTable
Field1: ID
Field2: EngineLevel
Field3: EngineBase
Field4: EngineName

ADOConnection = EnigmaConnection
TADODataSource = dsEnigma
TADOTable = tblEnigma


如果您需要更多详细信息,我会提供.

在此先谢谢您.


If you need more details, I''ll provide.

Thanks in advance.

推荐答案

如果您需要有关Delphi的帮助,请:
尝试使用ADO组件,所以
配置ADOConnection后(设置其连接字符串),然后将其属性设置为true,然后
添加ADOTable 并设置其连接和表,并将其Active设置为True
然后添加DataSource 并将其DataSet 设置为ADOTable
然后放置DataGrid并将其DataSource 设置为先前添加的数据源

如果要使用表中的单个行,请尝试观察ADOTable 方法.
还可以考虑使用ADOQuery ADOCommand.

祝你好运

发表评论后:
因此,如果您做了这些事情,便开始在ADOQuery SQL :
中编写您的SQL.
If you want help with Delphi then :
Try to work with ADO components , So
Add a ADOConnection after configuring it(setting its connection string) ,set its Active property to true then
Add a ADOTable and set its connection and table and set its Active to True
And then add a DataSource and set its DataSet to ADOTable
Then drop a DataGrid and set its DataSource to the previously added datasource

If you want to work with individual rows in table try to observe ADOTable methods.
Also consider using ADOQuery and ADOCommand.

Good Luck

After you comment :
So if you did these things start writing your SQLs in ADOQuery ''s SQL :
select * from EnigmaTable where ID=:id 


在要成为参数的每个名称后面都加上一个:".
并在执行ADOQuery数据集之前设置参数值.
运行SQL之后,您可以通过以下方式访问它们的值:


put a ":" behind every name that you want to become a parameter.
and set the parameters values before executing the ADOQuery datasets.
After running the SQL you can access their values by something like this :

Query1.FieldByName("EngineName").AsString


这篇关于从Access数据库读取文本和数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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