csharpdoost
چهارشنبه 25 بهمن 1391, 20:37 عصر
اشکال این کد چیه که خطا میده؟
sqlConnection.ConnectionString = ("Data Source=ALI-PC;Integrated security=true");
string dataBase = "CREATE DATABASE Hesabdari ON PRIMARY (NAME = Hesabdari, FILENAME = 'G:\\Hesabdari.mdf',SIZE = 3MB) LOG ON (NAME = Hesabdari_log, FILENAME = 'G:\\Hesabdari_log.ldf', SIZE = 1MB)";
cmd.CommandText = dataBase;
try
{
sqlConnection.Open();
cmd.ExecuteNonQuery();
sqlConnection.Close();
}
در دستور cmd.ExecuteNonQuery(); خطا میده
و این هم متن خطاش :
"ExecuteNonQuery: Connection property has not been initialized."
sqlConnection.ConnectionString = ("Data Source=ALI-PC;Integrated security=true");
string dataBase = "CREATE DATABASE Hesabdari ON PRIMARY (NAME = Hesabdari, FILENAME = 'G:\\Hesabdari.mdf',SIZE = 3MB) LOG ON (NAME = Hesabdari_log, FILENAME = 'G:\\Hesabdari_log.ldf', SIZE = 1MB)";
cmd.CommandText = dataBase;
try
{
sqlConnection.Open();
cmd.ExecuteNonQuery();
sqlConnection.Close();
}
در دستور cmd.ExecuteNonQuery(); خطا میده
و این هم متن خطاش :
"ExecuteNonQuery: Connection property has not been initialized."