delphi 数据库之不用数据源 以access为例(其他未试过)
在我做好学生管理系统时,发现要使用本软件必须配置数据库的数据源。于是我就想弄个脱离数据源的版本。构造思想:在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 +';';
步骤:
一:有这么一个界面
二、 先修改con1的属性
修改adoquery的属性
在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” 博客,服务器空间,请务必保留此出处
,香港服务器
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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

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

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.

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

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

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.

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
