日期:2014-05-18  浏览次数:20766 次

如何用代码实现在应用程序当前目录新建sql server数据库?
RT。
假如我建库的代码是这样:

C# code

str = "CREATE DATABASE MyDatabase ON PRIMARY " + 
"(NAME = MyDatabase_Data, " + 
"FILENAME = 'C:\\MyDatabaseData.mdf', " + 
"SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " + 
"LOG ON (NAME = MyDatabase_Log, " + 
"FILENAME = 'C:\\MyDatabaseLog.ldf', " + 
"SIZE = 1MB, " + 
"MAXSIZE = 5MB, " + 
"FILEGROWTH = 10%)"; 



现在里边的“FILENAME =”应该怎么改,就能实现题目的要求?

------解决方案--------------------
当前目录,可以不写目录,直接写文件名,或者自己组合,用

Application.ExecutablePath+"\\xxxxx.mdf"

Application.StartupPath