| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 486 人关注过本帖
标题:如何用代码实现在应用程序当前目录新建sql server数据库?
只看楼主 加入收藏
sunshine_sty
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-4-12
收藏
 问题点数:0 回复次数:0 
如何用代码实现在应用程序当前目录新建sql server数据库?
RT。我建了两次代码都不行,求大家指教,代码应该如何改
我建库的代码是这样子的:
程序代码:
string str = "CREATE DATABASE MyDatabase ON PRIMARY " +
           "(NAME = MyDatabase_Data, " +
           "FILENAME = '" + Application.ExecutablePath + "\\MyDatabaseData.mdf'," +
           "SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
           "LOG ON (NAME = MyDatabase_Log, " +
           "FILENAME = '" + Application.ExecutablePath+"\\MyDatabaseLog.ldf'," +
           "SIZE = 1MB, " +
           "MAXSIZE = 5MB, " +
           "FILEGROWTH = 10%)";

但出错了,在Application.ExecutablePath处显示:当前上下文不存在名称Application

改为:
程序代码:
string str = "CREATE DATABASE MyDatabase ON PRIMARY " +
            "(NAME = MyDatabase_Data, " +
            "FILENAME = Application.ExecutablePath+"+"\\MyDatabaseData.mdf,"+
            "SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
            "LOG ON (NAME = MyDatabase_Log, " +
            "FILENAME = Application.ExecutablePath+" + "\\MyDatabaseLog.ldf," +
            "SIZE = 1MB, " +
            "MAXSIZE = 5MB, " +
            "FILEGROWTH = 10%)";

也不行。
搜索更多相关主题的帖子: 数据库 目录 应用程序 server color 
2012-04-12 21:33
快速回复:如何用代码实现在应用程序当前目录新建sql server数据库?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028038 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved