send notification message to client - sql

I have a table in server. I want to show a notification message in client when that table will update. How can i do that? excuse me because I'm beginner in SQL

you can use triggers for that.. here some notes for triggers
SQL triggers
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/sqlp/rbafysqltrig.htm
Introduction to SQL Triggers
http://www.mysqltutorial.org/sql-triggers.aspx

Usually, this kind of thing should not be done on the database layer, but on the application layer where the change is initiated.
The database server is not really equipped to do this. It doesn't have E-Mail capabilities, and it has no notification system like the kind you talk about.

How about SQL2008 Query Notification? This is something different than Notification Services which was removed in SQL 2008. Query Notification is basically creating SqlDependency Object in a client application with a SELECT Query and then the SQL 2008 server notifies when there was any change in THE query result. Here's some client side code example.
I have never used this myself but am looking for a very minimalistic intranet chat client based on SQL database.
Happy coding.

Related

Which software/framework to use to create App for Call Calibration for Quality Dept

I'm not sure if this is the right place to ask this question. If not, please direct me to the right place.
We used to have an application that was created using VB and Microsoft Access. It was an application to score calls from Agents and would then run a few calculations and grade those agents based on a few algorithms.
We replicated all that Access data onto SQL but for some reason, we were just not able to connect the VB application to the SQL Database instead. The application was also outdated and we needed a change.
Can anyone suggest software/framework that can be used to create a new application with an ability to connect to a SQL database?
EDIT: We have a Microsoft Office 365 subscription. I was thinking of using PowerApps. I've never used it before. Does anyone think this could help serve my purpose?
I have extensive experience of using PowerApps to create applications connected to SQL Server (in my case Azure SQL Database), and am mostly satisfied.
There are some constraints, but not major. Please see these posts for some further information.
I would suggest PowerApps if you have Office365.

How do you configure a BizTalk WCF-SQL adapter to get data from a SQL Server 2012 "always on" replica database?

We have a client that is going to use the AlwaysOn Availability feature of SQL Server 2012.
They want to have the BizTalk WCF-SQL port connect to the read-only replica.
The documentation on the subject say that the connection has to be made to the SQL Server 2012 Availability Group Listener, and the connection has to be able to set the “ApplicationIntent” parameter. This tells the SQL Listener that the connection is a read-only intent connection, and that it should be redirected to a readable secondary replica. Without that working the connection will be made to the primary database which is not what is wanted.
How do you configure the “ApplicationIntent” parameter on a BizTalk WCF-SQL adapter?
There is no way of doing this via the WCF-SQL adapter.
We have had to go with an external helper class to create the connection with a connection string and query the database.
Update: A Blog written by a colleague on the issue Can I use a BizTalk WCF-SQL send adapter with a SQL 2012 Always on Database? a snippet quoted below.
In summary I think your choices are (in order of preference):
Disable AlwaysOn Availability Groups / Mirroring on SQL server if you need to connect to this SQL server which has this enabled
Disable transactions and implement logic to be able to handle duplicates .
Disable transactions and handle the duplicates or lost messages with custom logic (e.g. Send twice and compare and implement error handling). You need to write your own DTC handling this which is probably very complicated.
Disable transactions and live with risk of duplicates or lost messages without handling duplicates.
I think you'll need to go WCF-Custom + sqlBinding to specify a connection string.
In that link you gave, they did it in the connection string. Look at the last item in it:
Server=tcp:AGListener,1433;Database=AdventureWorks;
IntegratedSecurity=SSPI;ApplicationIntent=ReadOnly
Looks easy enough...

Push new row from SQL to vb.net

I want to get the data that is inserted into a table in at close to real time as I can.
For simplicity, let say i have a table called
"DataInput"
With the columns:
ID, Name, Time
What is the easiest way using VB.NET to get the row as soon as it gets inserted into the database?
Polling for a new record every second seems clunky.
Thanks.
For Sql Server - You can use Query Notifications
SQL Server 2005 introduced query notifications, new functionality that allows an application to request a notification from SQL Server when the results of a query change. Query notifications allow programmers to design applications that query the database only when there is a change to information that the application has previously retrieved.
Refer:
Using Query Notifications
Working with Query Notifications
Also, for .Net have a look at:
SqlCacheDependency Class:
On all supported versions of SQL Server (Microsoft SQL Server 7.0, Microsoft SQL Server 2000, and SQL Server 2005) the SqlCacheDependency class monitors a specific SQL Server database table. When the table changes, items associated with the table are removed from the Cache, and a new version of the item is added to the Cache.
Refer:
Using and Monitoring SQL 2005 Query Notification

Using a Trigger to Email from SQL Express

I would like to send an email from SQL Server 2005 Express using a trigger.
The solutions I have seen use the System Stored Procedures xp_sendmail
or sp_send_dbmail, but these are not available under SQL Express (will only work under full SQL Server).
Any suggestions would be appreciated.
Thanks
Sending an Email from a trigger sounds like a bad idea.
Why not poll the table and pick up modified records, then send an Email for each new/modified entry?
As Leather said, trying to send an email in a trigger is a bad idea.
While in my opinion upgrading to SQL Standard and using sp_send_dbmail is the best way to send email through a database, I believe you can accomplish what you want to do through the low-fi CDOSYS .
Described here: http://support.microsoft.com/kb/312839
I have not used CDOSYS since SQL 2000 so I don't know for sure that it will be your solution, but it does give you another avenue to learn about sending email pro grammatically.

tcp\ip server tracking database changes

I have a tcp\server ( .NET 3.5 ) that notifies connected clients about aah interesting events. These events occur because an aspx website is writing stuff to a database( SQL 2005 )
What would be a good way for this server to monitor the database so to speak
can the db push info to the server in any way?
any suggestions thoughts welcome
thanks
Take a look at SQL Broker Service - http://msdn.microsoft.com/en-us/library/ms345108(SQL.90).aspx.
To take this further you can use SqlDependency. There is a nice small article on CodeProject - http://www.codeproject.com/KB/database/chatter.aspx.
There are some caveats using it but many of them are already described on the web. Use the following resources:
http://www.wintellect.com/CS/blogs/jprosise/archive/2005/12/06/sqlcachedependency-hell.aspx
http://davidhayden.com/blog/dave/archive/2006/04/29/2929.aspx
SQL Broker services is quite vast to get in details with, but I hope I gave you good resources to start up with.
I had a similar problem. Needed instant notification of data insertion. I used SQL Broker Service and CLR stored procedure (written in C#). The procedure notify about the inserted data to another application using socket.
You can write similar CLR stored proc or CLR Trigger (Offcource asynchronous when using service broker)