public async Task <JsonResult> GetAPatientInfo(int PatientId) { #region another //-------------------------------------------------------------------------------- //Article result = new Article(); ////Create the SQL Query for returning an article category based on its primary key //string sqlQuery = String.Format("select * from Article where ArticleID={0}", articleId); ////Create and open a connection to SQL Server //SqlConnection connection = new SqlConnection(ConnectionString); //connection.Open(); //SqlCommand command = new SqlCommand(sqlQuery, connection); //SqlDataReader dataReader = command.ExecuteReader(); ////load into the result object the returned row from the database //if (dataReader.HasRows) //{ // while (dataReader.Read()) // { // result.ArticleId = Convert.ToInt32(dataReader["ArticleID"]); // result.Body = dataReader["Body"].ToString(); // result.CategoryId = Convert.ToInt32(dataReader["CategoryID"]); // result.PublishDate = Convert.ToDateTime(dataReader["PublishDate"]); // result.Title = dataReader["Title"].ToString(); // } //} //return result; //--------------------------------------------------------------------------------------- #endregion string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; TbPatientInfo patientInfo = new TbPatientInfo(); using (SqlConnection connection = new SqlConnection(connectionString)) { string sql = $"Select * From TbPatientInfo Where PatientId='{PatientId}'"; SqlCommand command = new SqlCommand(sql, connection); connection.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { patientInfo.PatientId = Convert.ToInt32(dataReader["PatientId"]); patientInfo.FirstName = Convert.ToString(dataReader["FirstName"]); patientInfo.LastName = Convert.ToString(dataReader["LastName"]); patientInfo.DOB = Convert.ToDateTime(dataReader["DOB"]); patientInfo.Email = Convert.ToString(dataReader["Email"]); patientInfo.PhoneNo = Convert.ToString(dataReader["PhoneNo"]); patientInfo.State = Convert.ToString(dataReader["State"]); patientInfo.LGA = Convert.ToString(dataReader["LGA"]); patientInfo.Gender = Convert.ToString(dataReader["Gender"]); patientInfo.BGroup = Convert.ToString(dataReader["BGroup"]); patientInfo.GType = Convert.ToString(dataReader["GType"]); patientInfo.DateCreated = Convert.ToDateTime(dataReader["DateCreated"]); } } connection.Close(); return(Json(ResponseData.SendSuccessMsg(message: null, data: patientInfo))); } return(Json(ResponseData.SendFailMsg(message: null, data: null))); }