M
Mark Moore
This seems like the most newbie question, but I can't find
the answer after 1/2 a day searching.
How can I create a new database on a (MSDE) SQL server
from .NET?
Here's the code I use, but it looks like ASPNET doesn't
have permission to create a new database.
{
SqlConnection myConnection = new SqlConnection
("Integrated Security=SSPI;Server=
(local);Database=rescopa");
SqlCommand cmd;
try
{
myConnection.Open();
}
catch ( SqlException e )
{
if ( e.Number != 4060 &&
e.Number != 911 ) throw
e; //BUGBUG: How does SqlException select for specific
errors?
SqlConnection conn2 = new SqlConnection
("User ID=sa;Server=(local)");
conn2.Open();
cmd = new SqlCommand( "CREATE DATABASE
rescopa", myConnection );
cmd.ExecuteNonQuery();
conn2.Close();
myConnection.Open();
}
}
the answer after 1/2 a day searching.
How can I create a new database on a (MSDE) SQL server
from .NET?
Here's the code I use, but it looks like ASPNET doesn't
have permission to create a new database.
{
SqlConnection myConnection = new SqlConnection
("Integrated Security=SSPI;Server=
(local);Database=rescopa");
SqlCommand cmd;
try
{
myConnection.Open();
}
catch ( SqlException e )
{
if ( e.Number != 4060 &&
e.Number != 911 ) throw
e; //BUGBUG: How does SqlException select for specific
errors?
SqlConnection conn2 = new SqlConnection
("User ID=sa;Server=(local)");
conn2.Open();
cmd = new SqlCommand( "CREATE DATABASE
rescopa", myConnection );
cmd.ExecuteNonQuery();
conn2.Close();
myConnection.Open();
}
}