I am writing a program that will create a new datatbase, then add tables to that datatbase. Here is my code....
InsertTable("Create Database iBlast", "Null");
InsertTable("Create Table iBlast.tblBoreHoles (HoleID uniqueIdentifier, HoleName nvarchar(40), JobID uniqueidentifier, CreateDate datetime, Longitude float, Latitude float, Altitude float, HoleDia real, ExpectedDepth float)", "iBlast");
static void InsertTable(String sqlQuery, string InitialCatalog)
{
SqlConnection sqlConn = new SqlConnection();
//sqlConn.ConnectionString = "Data Source=VIRTUAL2KB;Initial Catalog=PCS6000SQL;User ID=sa;Password=password;Integrated Security=False";
if (InitialCatalog == "Null")
{
sqlConn.ConnectionString = "Data Source=VEEMER11;Integrated Security=True";
}
else
{
sqlConn.ConnectionString = "Data Source=VEEMER11;Initial Catalog=" + InitialCatalog + ";Integrated Security=True";
}
sqlConn.Open();
SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConn);
sqlCommand.ExecuteNonQuery();
}
The database creation works fine but I get an error when the code trys to create the table.
Error = "The specified schema name "iBlast" either does not exist or you do not have permission to use it."
Any help would be appreciated.