从ASP.NET3.5执行存储过程
我需要帮助向系统过程传递前缀从ASP.NET3.5执行存储过程,asp.net,ado.net,Asp.net,Ado.net,我需要帮助向系统过程传递前缀 exec [your database name]..sp_tables 在上面的代码中,[您的数据库名称]应该是一个文本框值 这是我的密码 string DatabaseName = txtbox.Text; using (SqlDataAdapter sda = new SqlDataAdapter("exec ['"+DatabaseName+"']..sp_tables", conn)) { Data
exec [your database name]..sp_tables
在上面的代码中,[您的数据库名称]应该是一个文本框值
这是我的密码
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();
}
我犯了一个错误
Database '.net'' does not exist. Make sure that the name is entered correctly.
当我执行
exec [.net]..sp_tables
我得到的结果是正确的
有什么建议吗??
提前感谢。您正在预加和追加一个报价,因此会出现错误。DBnames不需要引号 尝试:
newsqldataadapter(“exec[“+DatabaseName+”]…sp_tables”,conn))
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();