在运行时创建Access数据库 [英] Creating Access Database at Run time

查看:99
本文介绍了在运行时创建Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好;

在运行时执行所有SQL命令(例如SELECT,INSERT,CREATE TABLE等)时,应正确设置两个对象.一个(用于Access数据库)是OleDbConnection,它通过其ConnectionString属性连接到所需的数据库.第二个是OleDbCommand,用于存储所需的SQL命令.因此,应该有一个在其上执行命令的数据库.我的问题是我想在运行时创建数据库,以便在通过OleDbConnection附加数据库之前没有数据库.尽管我知道用于创建数据库的SQL命令,但不知道OleDbConnection应该连接到哪里(由于没有prevoius数据库),但我不知道该怎么做.你能帮我吗?

非常感谢您

Hello;

In executing all SQL commands(like SELECT, INSERT, CREATE TABLE ,...) at runtime,there should be two objects set properly. One (for Access databases)is OleDbConnection, which gets connected to desireed database through its ConnectionString property. The second one is OleDbCommand where the needed SQL commands is stored. So there should be a database on which the command is performed. My problem is I want to make database at runtime so there is no database before to attach to by OleDbConnection. Although I know SQL comand for creating database, not knowing where OleDbConnection should get connected to (due to not having prevoius database), I do not know what to do. Could you please help me?

Thank you very much

推荐答案

处理此IMO的最佳方法是在项目中放入空白DB,并在要创建新DB时进行复制数据库.
The best way to handle this IMO, is to put a blank DB in with your project and make a copy when you want to create a new database.


这篇关于在运行时创建Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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