简体   繁体   中英

Error when I've executing query “Invalid object name 'sw.Switch'.”

I got an error when I execute a query in C#: I use schema in SQL Server, It's name is "sw". My table name is "Switch", My select operation is properly because I can execute it in sql server without any error, But when I use it in SQLDataAdaptor I got this error:

Invalid object name 'sw.Switch'.

This is my code:

try
{
adp = new SqlDataAdapter("Select * from sw.Switch " , con);
ds = new DataSet();
adp.Fill(ds,"sw.Switch");
return ds;
}
catch (Exception ex)
{
throw new Exception(ex.Message);    
}

What does your connection string look like?

I bet you're connecting to the master database by default instead of whatever database contains the sw schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM