Dear All,
I have a issue in connecting sql table value into signalr json query.
I am loading two value from table - descr(nvarchar) and uploadDate(DateTime).
I want to display date value in "dd/MM/yyyy format. Please help me on this.
The value from descr is loading perfectly by using below query:-
And the c# code I wrote to trigger this function is given below:-
- [WebMethod]
- public static IEnumerable
GetData() - {
- SqlDataReader reader = null;
- try
- {
- using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBase"].ConnectionString))
- {
- connection.Open();
- //using (SqlCommand command = new SqlCommand(@"SELECT [Description] FROM [dbo].[tblActionDetaills]", connection))
- //{
- using (SqlCommand command = new SqlCommand("SELECT Description,UploadDate FROM tblActionDetaills WHERE IsRead=0 AND VID='" + 1 + "' Order By UploadDate DESC", connection))
- {
- // Make sure the command object does not already have
- // a notification object associated with it.
- command.Notification = null;
- SqlDependency.Start(ConfigurationManager.ConnectionStrings["DataBase"].ConnectionString);
- SqlDependency dependency = new SqlDependency(command);
- dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
- if (connection.State == ConnectionState.Closed)
- connection.Open();
- using (reader = command.ExecuteReader())
- return reader.Cast
() - .Select(x => new Products()
- {
- Description = x.GetString(0),
- UploadDate = x.GetDateTime(1)
- }).ToList();
- }
- }
- }
I have attached a file where you can see how the value displaying in the web page. Please find that file.
Bineeshcp ViswanathPosted Apr 18, 2019, 3:42 AM
Bineeshcp ViswanathPosted Apr 18, 2019, 1:57 AM
Madan ShekarPosted Apr 18, 2019, 1:36 AM
Bineeshcp ViswanathPosted Apr 18, 2019, 1:34 AM
Madan ShekarPosted Apr 18, 2019, 12:32 AM