I have a C# source code for OPC server.
The code is working and I connect successfully but I have one big problem,
the data auto update does not work, in other words, I need to restart the server so it will
take the new data from the data base.
The code has an attribute named "updatePiriod", initialaized to 60000 ms and still, no auto updates.
There's more to getting data updates than simply connecting to the server. Have you 1) Created a Group; 2) Created items; 3) Activated the items; 4) Subscribed to callbacks?
Related
Recently created a C# tool using SMO class to automate the refactor and merge of SQL Server databases for migration into Azure.
The TransferData method successfully adheres to the BulkCopyTimeout for the data copy phase; proved this by extending it when it timed out.
When the transfer phase moves to CREATE INDEX statements they appear to hit a timeout after 120sec / 2mins on a particularly large table.
The ServerConnection object has StatementTimeout and ConnectionTimeout both set to 0 (as initial research suggested doing) to no avail.
Running a profiler trace, I noticed the "Application Name" differs from the original set (MergeDB v1.8) when the bulk copy and index create phases are running.
The original connection is still present but it appears that the Transfer class spawns additional connections (but whilst appearing to pass on BulkCopyTimeout; failing to pass on the application name and (my hypothesis) the StatementTimeout property.
I'm using SMO v150.18131.0 connecting to SQL 2008 R2.
Is there any way to notify working console application (call certain method) in case of any rows were added in the SQL Server 2012 DB table from anywhere?
1) One solution is to use Query Notification.
Quote:
Built upon the Service Broker infrastructure, query notifications
allow applications to be notified when data has changed.
http://msdn.microsoft.com/en-us/library/t9x04ed2(v=vs.110).aspx
https://www.simple-talk.com/sql/t-sql-programming/using-and-monitoring-sql-2005-query-notification/
2) Another solution could be
a simple AFTER INSERT/UPDATE/DELETE trigger that call sp_trace_generateevent
plus an extended events session which intercept user_event event (see here)
plus XEvent API > Microsoft.SqlServer.XEvent.Linq.dll, QueryableXEventData (see demo)
I have a winforms client application which is written in c# 4.0 that sends
a simple datatable (in a dataset) to the server , which is written in vb.net 4.0.
The datatable is sent through a web service.
both client and server are on the same computer.
This has been working fine for many years.
Now I get a strange behaviour with a datatable generated from a csv file.
Here it how it looks on the client side:
and here is the server side:
for some reason, the first row time has shifted from 2:55 AM to 03:55 in the server.
This results in a duplicate key. what's up with that?
one of the strangest bugs I've ancountered. would appreciate any help with this one -
thanks.
As suggested by #mikey,
the problem was that client used a local user account
whereas the server used the IIS acount.
One of those acounts was set to use daylightsaving time,
the other was not.
In my country, daylight saving time ended on march 29,
so this resulted in a conflict between server time and client time,
even though both were on the same computer.
Mikey , thanks again :)
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).
I have a copy of client database say 'DBCopy' which already contains modified data. The copy of the client database (DBCopy) is attached to the SQL Server where the Central Database (DBCentral) exists. Then I want to update whatever
changes already present in DBCopy to DBCentral. Both DBCopy and DBCentral have same schema. How can i do it programatically using C#.NET maybe with a button click. Can you give me an example code as how to do it?. I am using SQL Server 2005 Standard Edition and VS 2008 SP1.
In the actual scenario there are about 7 client database all with same schema as the central database. I am bringing copy of each client database and attach it to Central Server where the central database resides and try to update changes present in each copy of the client database to central database one by one programatically using C# .NET . The clients and the central server are physically seperate machines present in different places. They are not interconnected.
I need to only update and insert new data. I am not bothered about deletion of data.
Thanks and regards
Pavan
Go check out Sync Framework. Otherwise, go create some SSIS packages and run them.
What you are describing sounds an awful lot like Database Mirroring.
If this is a one-time or infrequent sync, then I'd use a third-party tool such as Red-Gate's SQL Data Compare. If this is meant as an ongoing sync, then I'd recommend replication or the Synchronization Framework.
i think this is wht u want:-----
USE DB1
UPDATE DB1.dbo.MyTable
SET
Field1 = d2.Field1,
Field2 = d2.Field2,
Field3 = d2.Field3
FROM DB2.dbo.MyTable d2
WHERE d2.MyKey = MyTable.MyKey