i need help in passing prefix to a system procedure..
exec [your database name]..sp_tables
Here in above code the [your database name] should be a textbox value
here is my code..
string DatabaseName = txtbox.Text;
using (SqlDataAdapter sda = new SqlDataAdapter("exec ['"+DatabaseName+"']..sp_tables", conn))
{
DataSet ds = new DataSet();
sda.Fill(ds);
DropDownList2.DataTextField = "TABLE_NAME";
DropDownList2.DataSource = ds;
DropDownList2.DataBind();
}
I am getting error
Database '.net'' does not exist. Make sure that the name is entered correctly.
when I execute
exec [.net]..sp_tables
I get the result correctly
Any suggestion ??
Thanks in Advance..
You’re prepending and appending a single quote thus the error. DBnames dont need the quotes.
Try:
new SqlDataAdapter("exec ["+DatabaseName+"]..sp_tables", conn))