How to raise an event in VB.NET when a row is added to an SQL Server table -


not sure possible. currently, detect row has been added table in sql server, use timer query table. there way sql server (presumably via ado.net sqlconnection object) can raise event in visual basic when row added, don't need keep polling/querying database?

if using sql server 2005+, can use service broker , query notifications. the setup bit complicated. in short use sqldependency class.
dependency first has created

system.data.sqlclient.sqldependency.start(cs) 

and can used

dim cmd new sqlcommand(sqlquery, cn) cmd.commandtext = "select field dbo.mytable"  sqld = new sqldependency(cmd)   cn.open() dim tbl new datatable tbl.load(cmd.executereader)  addhandler sqld.onchange, addressof tablechanged 

the dependency should not used lot of clients , there strict rules (creating query notification) how query should written.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -