简体   繁体   中英

sql dependency Invalid object name '

I am trying to use sql dependence, and I tried with making the connection with the squery, it is a very simple code:

public MyListener()
        {
            string query = "SELECT * FROM TransferToSIP WHERE hasBeenRead = false";
            SqlDependency.Start(getConnectionString(), query);
        }

That is the constructor. i call it like this:

new MyListener();

but I got this exception:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Invalid object name 'SELECT * FROM TransferToSIP WHERE hasBeenRead = false'.

There is no mistake at all in the database name or the field name.

what am i doing wrong please?

Try specifying a queue name instead of a query, or even without queue.

An example can be found on the reference page: https://msdn.microsoft.com/en-us/library/62xk7953%28v=vs.110%29.aspx

如果column(hasBeenRead)数据类型是位字符串,请尝试执行以下操作:查询=“ SELECT * FROM TransferToSIP WHERE hasBeenRead ='false'”;

"*" is not allowed. Try a selct statement with field names and maybe a dbowner

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