Issue with Datetime in SQL Server and C# code

Error String

SqlConnection _sc = new SqlConnection(conStr);
SqlCommand _scmd = new SqlCommand("Select b.ProductName,Region, Count(UserID) as UserCount from T_DeletedUsers a,T_Products b Where a.CreatedDate <='dxFromDate' and a.ModifiedDate >'dxFromDate' and FK_Products=b.ID Group by Region,b.ProductName union Select b.ProductName,Region, Count(UserID) as UserCount from dbo.T_Users a,T_Products b Where a.CreatedDate <='dxFromDate' and a.ModifiedDate >'dxFromDate' and FK_Products=b.ID Group by Region,b.ProductName", _sc);
SqlDataAdapter _sad = new SqlDataAdapter(_scmd);
_sad.Fill(dtUsers);-------------error raise (System.Data.SqlClient.SqlException was unhandled by user code)
return dtUsers;
}

error msg

System.Data.SqlClient.SqlException was unhandled by user code
Message=Conversion failed when converting datetime from character string.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=241
Procedure=""
State=1
StackTrace:

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.HasMoreRows()
at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer
dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords,
String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at PeriodMetrics.GetdatewiseUserMetrics(DateTime dxFromDate) in
c:\Users\Joseph\Documents\Visual Studio 2010\WebSites\reprt\App_Code\PeriodMetrics.cs:line 41
at reprt2.ASPxButton1_Click(Object sender, EventArgs e) in c:\Users\Joseph\Documents\Visual Studio 2010\WebSites\reprt\reprt2.aspx.cs:line 24
at DevExpress.Web.ASPxEditors.ASPxButton.OnClick(EventArgs e)
at DevExpress.Web.ASPxEditors.ASPxButton.RaisePostBackEvent(String eventArgument)
at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
t System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
t System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: 

Fix

It's a straight forward issue and clearly indicates that the issue is resolving around date field.

You need to use convert operation in this area convert(datetime, 'dxFromDate',103) .