Hi,
I've created a database using this Stored Procedure.
ALTER PROCEDURE dbo.StoredProcedure1
(
@DatabaseName VARCHAR(50) = 'SampleDB'
)
AS
BEGIN
SET NOCOUNT ON
EXECUTE('CREATE DATABASE ' + @DatabaseName);
END
Executed it in ASP.net web page
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=<local computer path>\App_Data\ssdb_main.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand dbc = new SqlCommand("StoredProcedure1", con);
dbc.CommandType = System.Data.CommandType.StoredProcedure;
dbc.Parameters.Add(new SqlParameter("@DatabaseName", "MyNewSampleDB"));
dbc.ExecuteNonQuery();
con.Close();
It executed successfully but I cannot find the database. I rerun it and it says it that the database has already existed? Where can I find it? I tried in C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA AND C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA but the database is not in there..
Help anyone?
Thanks