i was trying to connect a local machine with my web application.i need to get some data from local machine and insert it into my online table.User clicks a button and a new column is added to a online table named request which has status "new" in the beginning.i went for sql dependency which i installed as a windows service in local machine and it check the request table for any new insert.the service fetches some data from the local machine and posts it to the online database and change the status field in request table to "updated".
Now my problem is how can i notify my website that required data has been inserted in the table?? i need to watch the request table continuously until the value in the status column changes to updated.can i go for thread or timer ??
You can write an INSERT trigger in the live database which your website is using.
Use another Table RequestUpdates and write an INSERT trigger that adds a value to the table RequestUpdates in the live database.
Design your website to load the RequestUpdates table.
And when the user loggs in and Requests have been viewed, change the status in the live table to viewed.
In this way new requests will be shown that are not viewed the next time.
Related
I need to know the best way to monitor a SQL server DB table if it is updated everyday or not. If it is not updated on a particular day, then send an alert message to a particular mail.
Create a job on SQL Server Agent that runs every day. On that job, design a script that checks if the table is updated.
To check if the table is updated, you should do something like save the value of a particular column from the previous day and compare it to the value of n from the current day.
Or you can design a trigger on that table. If the table is updated, the trigger will fire and save somewhere the fact that the table was updated.
If the table is not updated send an email.
If you don't know how to sent an email from SQL server here are the steps you should follow:some steps
I have a web service that inserts a row into a Database Table.
After this a windows service will read this table and updates this table.
Inserts a Blob into FILE_IMAGE column
STATUS to COMPLETE
My Web Service has to wait till this table STATUS and FILE_IMAGE column gets updated and then read the FILE_IMAGE.
My doubt is : What logic is ideal for my web service to wait for the table to get updated.
I dont want to use Thread.Sleep or something similar to that. My database is Oracle and code behind is C#.
You could write an AFTER UPDATE trigger on the oracle table which sends the ROWID to another web service which performs the necessary steps. Thread.Sleep will always have the potential of not waiting long enough.
I have a bit of a problem. I am loading a .CSV file's contents into a DataGridView to locally edit rows whilst the our network is offline.
Once the network comes online again, I need to be able run update or insert from a local datagridview to take the contents to the SQL Server and update those rows that already exist.
At the moment I'm using a SqlBulkCopy however I cannot edit records on application once this has uploaded as it tries to add a new record and the database obviously throws back a PK constraint breach.
Any ideas?
I'm coding a M2M data capture system using SQL Server 2012 and .net 4.5, the scenario is:
I have a remote data capture app, a web service, a DB.
The app captures data and invoke the web service to upload the data to the DB.
The web service call a "insert" storedproc to write raw data directly in Table A; and then, the web service returns a value telling that the insert was successful or not.
Now, a post-process storedproc needs to be run after the insert process to update another table (Table B).
Previously I used 'job agent' but since the required polling interval changed to 'less than 5 minutes', for the efficiency and real-time reason, I want to avoid to use the 'polling'.
Ideally, I want the app to be able to call the web service and get the return message/value, after that, the DB fires a stored proc to do the post-process work; the work may take longer so the app doesn't need to wait all the processes are done.
Can I fire the post-process sp from DB side? since the DB knows when the insert is done, and it saves communications from outside the DB.
Any suggestions?
You might think of using trigger plus Service Broker. In this way, the trigger will send a message to a queue. service broker will be fired to process the message. It decouples your table A update and table B update. If only use trigger to call table B, it will hold your table A update until the table B update finished.
I created a windows forms application in C #, and a database MS SQL server 2008 Express, and I use LINQ-to-SQL query to insert and edit data.
The database is housed on a server with Windows Server 2008 R2 (standard edition). Right now I have the application running on five different computers, and users are authenticated through active directory.
One complaint reported to me was that sometimes when different data is entered and submitted, the same data do not appear in the listing that contains the application. I use try catch block to send the errors but errors do not appear in the application; but the data simply disappear.
The id of the table records is an integer auto-increment. As I have to tell them the registration number that was entered I use the following piece of code:
try{
ConectionDataContext db = new ConectionDataContext();
Table_Registers tr = new Table_Registers();
tr.Name=textbox1.text;
tr.sector=textbox2.text;
db.Table_Registers.InsertOnSubmit(tr);
db.SubmitChanges();
int numberRegister=tr.NumberRegister;
MessageBox.Show(tr.ToString());
}
catch{Exception e}
I wonder if I'm doing something wrong or if you know of any article on the web that speaks how to insert data from different clients in MSSQL Server databases, please let me know.
Thanks.
That's what a database server DOES: "insert data simultaneously from different clients".
One thing you can do is to consider "transactions":
http://www.sqlteam.com/article/introduction-to-transactions
Another thing you can (and should!) do is to insure as much work as possible is done on the server, by using "stored procedures":
http://www.sql-server-performance.com/2003/stored-procedures-basics/
You should also check the SQL Server error logs, especially for potential deadlocks. You can see these in your SSMS GUI, or in the "logs" directory under your SQL Server installation.
But the FIRST thing you need to do is to determine exactly what's going on. Since you've only got MSSQL Express (which is not a good choice for production use!), perhaps the easiest approach is to create a "log" table: insert an entry in your "log" every time you insert a row in the real table, and see if stuff is "missing" (i.e. you have more entires in the log table than the data table).