你好; 在运行时执行所有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数据库
发布评论