J
John Aldrin
Hi,
I'm wondering if it is possible to execute a sql command to drop a
database with a SqlParameter containing the name of the db to drop.
I've tried the following and I get an error
SqlCommand dropDbSqlCmd = _masterDbConn.CreateCommand ();
dropDbSqlCmd.CommandType = CommandType.Text;
dropDbSqlCmd.CommandText = "DROP DATABASE @dbToDrop";
SqlParameter dbNameParam = dropDbSqlCmd.Parameters.Add ( @dbToDrop,
SqlDbType.NVarChar, 128 );
dbNameParam.Value = dbName;
Error is
System.Data.SqlClient.SqlException : Line 1: Incorrect syntax near
'@dbToDrop'.
Thanx
jra
I'm wondering if it is possible to execute a sql command to drop a
database with a SqlParameter containing the name of the db to drop.
I've tried the following and I get an error
SqlCommand dropDbSqlCmd = _masterDbConn.CreateCommand ();
dropDbSqlCmd.CommandType = CommandType.Text;
dropDbSqlCmd.CommandText = "DROP DATABASE @dbToDrop";
SqlParameter dbNameParam = dropDbSqlCmd.Parameters.Add ( @dbToDrop,
SqlDbType.NVarChar, 128 );
dbNameParam.Value = dbName;
Error is
System.Data.SqlClient.SqlException : Line 1: Incorrect syntax near
'@dbToDrop'.
Thanx
jra