Home Database Mysql Tutorial delphi 数据库之不用数据源 以access为例(其他未试过)

delphi 数据库之不用数据源 以access为例(其他未试过)

Jun 07, 2016 pm 05:42 PM
datasource delphi data source

在我做好学生管理系统时,发现要使用本软件必须配置数据库的数据源。于是我就想弄个脱离数据源的版本。构造思想:在con1的connectionstring有链接数据库文件作为

Provider=Microsoft.Jet.OleDb.4.0(ACCESS数据引擎)

),网站空间,而Data Source写为绝对路径。


技术关键:

   1.获得程序所在目录,构造绝对路径:

sDBPath = extractFilepath(application.ExeName)+'dataname.mdb';

   2.con1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + sDBPath +';';

步骤:

一:有这么一个界面

 delphi 数据库之不用数据源 以access为例(其他未试过)

二、 先修改con1的属性

 delphi 数据库之不用数据源 以access为例(其他未试过)


修改adoquery的属性

 delphi 数据库之不用数据源 以access为例(其他未试过)

   在form2添加onActivate事件(窗口激活事件)代码如下,  

procedure TForm2.FormActivate(Sender: TObject); var sDBPath : string; begin sDBPath := extractFilepath(application.ExeName) + 'students.mdb'; ADOQuery1.Active := false; con1.Connected := false; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from admins'); //这句看窗口刚刚建立是否要数据库而定要写不写。 //User ID=Admin;数据库有用户名的相应的加上 //填写connectionstring con1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + sDBPath +';'; con1.Connected := true; ADOQuery1.Active := true; end;


这样就完成数据库脱离数据源的配置。

样例代码 ?shareid=187085761&uk=2065228996


本文出自 “lilin9105” 博客,服务器空间,请务必保留此出处

,香港服务器
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Power BI cannot connect, an error was encountered while trying to connect Power BI cannot connect, an error was encountered while trying to connect Feb 18, 2024 pm 05:48 PM

PowerBI may encounter difficulties when it cannot connect to a data source that is an XLS, SQL, or Excel file. This article will explore possible solutions to help you resolve this issue. This article will guide you on what to do if you encounter errors or connection failures during the connection process. So, if you are facing this problem, keep reading and we will provide you with some useful suggestions. What is the gateway connection error in PowerBI? Gateway errors in PowerBI are often caused by a mismatch between the data source information and the underlying dataset. To solve this problem, you need to ensure that the data source defined on the local data gateway is accurate and consistent with the data source specified in PowerBI desktop. PowerBI cannot connect

How to use Dynamic Datasource to configure multiple data sources in SpringBoot How to use Dynamic Datasource to configure multiple data sources in SpringBoot May 16, 2023 pm 07:07 PM

Functional features: Supports data source grouping, suitable for various scenarios, pure multi-database read and write separation, one master and multiple slave hybrid mode. Supports startup without data source and configuration of lazy startup data source (3.3.2+). Supports database sensitive configuration information encryption ENC(). Supports independent initialization of table structure schema and database database for each database. Supports custom annotations and needs to inherit DS (3.2.0+). Provides fast integration for Druid, Mybatis-Plus, P6sy, Jndi. Simplify Druid and HikariCp configuration and provide global parameter configuration. Configure once and use it globally. Provide customized data source source scheme. Provides a solution to dynamically add and remove data sources after the project is started. Provide M

Detailed explanation of the steps to implement batch Insert operations using MyBatis Detailed explanation of the steps to implement batch Insert operations using MyBatis Feb 22, 2024 pm 08:27 PM

Title: How to use MyBatis to implement batch Insert operations MyBatis is an excellent persistence layer framework that is widely used in Java development. In actual development, we often encounter situations where we need to insert data in batches. This article will introduce in detail how to use MyBatis to implement batch Insert operations, with specific code examples. Step 1: Configure MyBatis. Introduce MyBatis into the project and configure MyBatis related information, including database connection information, Ma

What does data source mean? What does data source mean? Jul 25, 2022 am 11:31 AM

Data source means "database or database server used by database applications"; data source is also the source of data, which is a device or original media that provides certain required data. All the information required to establish a database connection are stored in the data source. Information, by providing the correct data source name, the corresponding database connection can be found.

Data extraction in Yii framework: getting data from different data sources Data extraction in Yii framework: getting data from different data sources Jun 21, 2023 am 11:37 AM

With the rapid development of the Internet, data has become an important resource for enterprise development. In order to make better use of data, we need to extract data from different data sources for analysis and processing. In this article, we will focus on how to get data from different data sources in Yii framework. 1. Extract data from the MySQL database MySQL is one of the most popular relational databases at present. Its installation and use are very simple. Below we will introduce how to extract data from MySQL database in Yii framework

PHP PDO and ODBC: Connecting to various data sources PHP PDO and ODBC: Connecting to various data sources Feb 20, 2024 am 10:20 AM

PHPPDOPHPPDO (phpDataObjects) is an object-oriented data access abstraction layer that allows developers to connect to various database management systems (DBMS) using a unified interface. It provides a standard way to interact with a database, regardless of the underlying DBMS. Advantages of PDO: Unified interface: PDO provides a unified API for connecting, executing queries and obtaining results, thus simplifying interaction with different DBMS. PreparedStatements: PDO supports prepared statements, which helps prevent SQL injection attacks and improve performance. Transaction support: PDO allows managing transactions to ensure that database operations either all succeed or all fail. Error handling :P

What language is delphi? What language is delphi? Aug 10, 2023 pm 04:08 PM

delphi is a programming language and integrated development environment developed by Embarcadero Technologies. Delphi is an implementation of the Object Pascal language. It is widely used in software development based on Windows operating systems. Delphi is famous for its rapid development and stability. Whether engaged in desktop development or mobile development, Delphi is used by many developers. One of the tools of choice.

Take stock of more than 20 powerful and free data sources that anyone can use to build AI Take stock of more than 20 powerful and free data sources that anyone can use to build AI Jun 05, 2023 pm 02:29 PM

When we talk about artificial intelligence in business and society today, we’re really referring to machine learning. Machine learning is an application that uses an algorithm (a set of instructions) to become better and better at performing a specific task as it is exposed to more and more data relevant to that task. These tasks can be anything from answering questions, creating text or images (as apps like ChatGPT or Dall-E can do) to recognizing images (computer vision) or navigating a self-driving car from point A to point B. All of these tasks require data, and businesses that want to train their own machine learning algorithms to automate routine tasks will need some source of data. What types of data are there? Enterprise data is generally divided into two categories - internal data and external

See all articles