Background:
I am using sql statements to create a Temp database on a server which will store data until it is needed further by my client program.
Problem:
My sql statement to create the database works properly and creates the database with all the required specifications when run through Sql Management studio, on the other hand when my program executes the statement it only creates a database with the 'Default' settings except for the name.
Questions:
- Why is this?
- How can I make it create a database with my specifications
Sql statement:
CREATE DATABASE Temp ON PRIMARY( NAME = Temp , FILENAME = 'C:\Temp.mdf' , SIZE = 2MB , FILEGROWTH = 10%) LOG ON ( NAME = Temp_Log , FILENAME = 'C:\Temp.ldf' , SIZE = 1MB, MAXSIZE = 70MB , FILEGROWTH = 10%)
Code:
public void AcuConvert()
{
using (DestD)
{
SqlCommand command = new SqlCommand();
DestD.Open();
command.Connection = DestD;
foreach (var item in Entity.SqlDestinationQueries.ToList())
{
command.CommandText = item.Query;
command.ExecuteNonQuery(); //This is where the command is run
}
foreach (var item in Entity.SystemQueries.ToList())
{
command.CommandText = item.Query.Replace("@Sys", SysD.Database);
command.ExecuteNonQuery();
}
foreach (var item in Entity.InsertQueries.ToList())
{
command.CommandText = item.Query.Replace("@Source", SourceD.Database); ;
command.ExecuteNonQuery();
}
}
}