为了账号安全,请及时绑定邮箱和手机立即绑定

如何用代码实现在应用程序当前目录新建sql server数据库?

如何用代码实现在应用程序当前目录新建sql server数据库?

一只甜甜圈 2018-12-06 13:22:52
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%)"; 也不行。
查看完整描述

1 回答

?
青春有我

TA贡献1784条经验 获得超8个赞

是什么类型的程序(webform 或 winform)是否引用了“using System.Windows.Forms;”这个命名空间,写法应该是第一种,你断点调试一下

查看完整回答
反对 回复 2019-01-07
  • 1 回答
  • 0 关注
  • 507 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信