我对C#项目工作(WinForm的)
我安装SQL Server 2008 Express的客户端PC。
在开始我的计划必须创建一个数据库。 所以我使用此代码为创建数据库:
string sqlCreateDBQuery;
SqlConnection tmpConn = new SqlConnection(@"SERVER =.\SQLEXPRESS; Trusted_Connection = yes;DATABASE = master;");
sqlCreateDBQuery = " CREATE DATABASE "
+ DatabaseName
+ " ON PRIMARY "
+ " (NAME = " + DatabaseName + ", "
+ " FILENAME = '" + @"C:" + @"\" + DatabaseName + ".mdf" + "', "
+ " SIZE = 3MB,"
+ " FILEGROWTH = " + "10%" + ") "
+ " LOG ON (NAME =" + "MyDatabase_Log" + ", "
+ " FILENAME = '" + @"C:" + @"\" + DatabaseName + "_log.ldf" + "', "
+ " SIZE = 1MB, "
+ " FILEGROWTH = " + "10%" + ") ";
sqlCreateDBQuery = Coomand;
SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, tmpConn);
try
{
tmpConn.Open();
MessageBox.Show(sqlCreateDBQuery);
myCommand.ExecuteNonQuery();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
tmpConn.Close();
}
return;
但是当我的程序运行我见下错误
什么是我的问题?