I Work on C# Project (WinForm)
I Install Sql Server 2008 Express On Client PC.
in Start Of My Program Must Create a Database. So I Use This Code For Create a Database:
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;
But When My Program Run I See Following Error
What is My Problem?