I am running a SQL query on SQL Server inside of my WPF C# application. The query returns a string which contains the value called MYCOUNT
that I want to return to GetNumber
. How do I return the value MYCOUNT
only to get number and not the entire string?
public string GetNumber(string SkillNumber)
{
DateTime dte = DateTime.Today;
string fixedStartDate = String.Format("{0:yyyy-MM-dd " + "05:00:00.000" + "}", dte);
string fixedEndDate = String.Format("{0:yyyy-MM-dd " + "05:00:00.000" + "}", dte.AddDays(1));
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(SQLHelper.CnnCal("OADB")))
{
var x = connection.Query($"SELECT COUNT(SOURCEID) AS 'MYCOUNT' "
+ "FROM [OADB].[oadb].[CmsCallHistory] "
+ "WHERE disposition = 2 and DISPSPLIT in (" + SkillNumber + ") AND SEGSTOP BETWEEN '" +
fixedStartDate + "' and '" + fixedEndDate + "'");
return x.ToString();
}
}
This is what returns. I only need to return the value: