Hi,
I write you a sample stored procedure for what you need.
Please note that dpssp_InsertOrUpdate is the stored procedure name, and that i make assumptions about input parameters based on your code.
Is necessary to write the insert and update statement in the respective comment.
CREATE PROCEDURE dbo.dpssp_InsertOrUpdate
(
@Dispatcher nvarchar(max),
@DPSNum nvarchar(max),
@DPSType nvarchar(max),
@DT datetime,
@Queue nvarchar(max)
)
AS
BEGIN
IF EXISTS(
SELECT Dispatcher
FROM dps_data
WHERE
DispatcherName = @Dispatcher
AND DispatchNumber = @DPSNum
AND DPSType = @DPSType
AND [DateTime] = @DT
AND Queue = @Queue
)
BEGIN
END
ELSE
BEGIN
END
END
You will need to use a sql client like management studio for create the stored procedure in the database engine.
In the code you need to change your sql command to something like this:
SqlConnection conn = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "dbo.dpssp_InsertOrUpdate";
cmd.Connection = conn;
conn.Open();
cmd.Parameters.Add(new SqlParameter("@Dispatcher", sDispatcher));
cmd.Parameters.Add(new SqlParameter("@DPSNum", sDPSNum));
cmd.Parameters.Add(new SqlParameter("@DPSType", sDPSType));
cmd.Parameters.Add(new SqlParameter("@DT", dtDT));
cmd.Parameters.Add(new SqlParameter("@Queue", sQueue));
int result = cmd.ExecuteNonQuery();
conn.Close();
----------------------------------------------------------------------
Good luck.