在运行时创建Access数据库

编程入门 行业动态 更新时间:2024-10-26 12:30:29
本文介绍了在运行时创建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数据库

本文发布于:2023-11-30 21:38:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651548.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!