数据库路径问题
如果用create database db1则直接创建在sql2005的默认文件夹下
如果我想建在项目文件夹下,应该怎么建,不使用用全路径;
大家看我代码什么地方有问题
string sql = "CREATE DATABASE " + DataName + " ON PRIMARY " +
"(NAME = "+DataName+ ", " +
"FILENAME = '..\\ " + DataName + ".mdf ', " +
"SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
"LOG ON (NAME = " + DataName + "_log, " +
"FILENAME = '..\\ " + DataName + "_Log ', " +
"SIZE = 1MB, " +
"MAXSIZE = 5MB, " +
"FILEGROWTH = 10%) ";
------解决方案--------------------System.Web.HttpContext.Current.Server.MapPath
------解决方案--------------------b/s就用MapPath
楼主是winform? 对了,楼主有没有试过使用StartupPath时,输出/监视一下你的sql变量里的值,看看他生成了一个什么字符串.
------解决方案--------------------把字符串拿来一看不就知道了?