I have written some code that connects to an API, returns data and populates in a SQL DB, this occurs every 1 minute as the data is dynamic.
I then have a C# app that looks at the db and refreshes itself every 5 seconds.
The problem I am facing is that, I am using a delete * statement during each timer event, as I do not want duplicates in the DB, and when this happens, for about 5 seconds, whilst the data is populating in the DB, the C# application goes blank ( which is to be expected).
I do use the Merge statement in another db, but I cannot indicate the source as a webservice (As far as I am aware) so taht wont help me here.
How do I go about successfully avoid duplicates in the DB, without using a delete * statement, without losing visual data loss?

Vishal JadavPosted Sep 19, 2016, 3:05 AM
Derek HanekomPosted Sep 19, 2016, 1:43 AM
Tapan PatelPosted Sep 13, 2016, 3:35 PM
Vishal JadavPosted Sep 13, 2016, 4:01 AM
Derek HanekomPosted Sep 13, 2016, 3:51 AM
if (Deviceissue[index].Key.Equals("activeissue.devicename"))
{
name = Deviceissue[index].Value;
}
else if (Deviceissue[index].Key.Equals("activeissue.servicename"))
{
serviceName = Deviceissue[index].Value;
}
else if (Deviceissue[index].Key.Equals("activeissue.customername"))
{
customerName = Deviceissue[index].Value;
}
else if (Deviceissue[index].Key.Equals("activeissue.socustomername"))
{
soName = Deviceissue[index].Value;
}
else if (Deviceissue[index].Key.Equals("activeissue.deviceclass"))
{
deviceClass = Deviceissue[index].Value;
}
index++;
string varRetuned = deviceClass;
if (string.Equals(varLookFor, varRetuned))
{
// Console.WriteLine(name + " is a " + deviceClass + " Status is " + serviceName + " for " + customerName + " under the SO " + soName);
}
{
{
// Console.WriteLine(name + " ServiceName: " + serviceName + deviceClass);
}
// Write Data to SQL
String InsertQuery = "INSERT INTO ActiveIssue (CustomerName,ServerName,Type,DeviceClass) VALUES ('" + customerName + "','" + name + "','" + serviceName + "','" + deviceClass + "');";
SqlConnection Connection = new SqlConnection("Server=444LAB-NABLEDEV\\NEW_VANTAGE;Initial Catalog=msd;User ID=sa;[email protected]");
SqlCommand InsertCommand = new SqlCommand(InsertQuery, Connection);
Connection.Open();
InsertCommand.ExecuteNonQuery();
Connection.Close();
}
}
}
catch (Exception exception)
{
Console.WriteLine("Error:" + exception.Message);
}
// Add so that data can be viewed before program exits.
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(30));
Vishal JadavPosted Sep 13, 2016, 2:45 AM
Derek HanekomPosted Sep 13, 2016, 2:29 AM
Bikesh SrivastavaPosted Sep 13, 2016, 2:15 AM
Vishal JadavPosted Sep 12, 2016, 10:26 AM
Derek HanekomPosted Sep 12, 2016, 10:21 AM
Vishal JadavPosted Sep 12, 2016, 10:12 AM