1. my json file
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } },
"ConnectionStrings": { "Database": "Data Source=;Initial Catalog=BookingService;TrustServerCertificate=True;User ID=sa; Password=PFCLP@08122022;Integrated Security=false;" }, "AllowedHosts": "*" }
2. Database Connection Method
public static SqlConnection GetDbCon() {
try { SqlConnection con = new SqlConnection(); con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStrings"].ConnectionString; return con; }
catch (Exception ex) { throw ex; }
}
3. Data Access Method
public static List<BookingReferenceTbl> GetBookingDetailsPARA(string BookingRefNo) { using (SqlConnection SqlCn = DBMasterCon.GetDbCon()) { SqlCommand cmd = new SqlCommand("SPVM_BookingReferenceTblPARA", SqlCn); cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@BookingRefNo", SqlDbType.VarChar, 50).Value = BookingRefNo; SqlCn.Open();
List<BookingReferenceTbl> csd = new List<BookingReferenceTbl>(); try { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { BookingReferenceTbl grdcsd = new BookingReferenceTbl();
grdcsd.BookingRefNo = (string)Convert.ToString(reader["BookingRefNo"]); grdcsd.ReturnOption = (string)System.Convert.ToString(reader["ReturnOption"]); grdcsd.OneWayOption = (string)System.Convert.ToString(reader["OneWayOption"]); grdcsd.MultiCityOption = (String)System.Convert.ToString(reader["MultiCityOption"]); grdcsd.TravelFrom = (string)Convert.ToString(reader["TravelFrom"]); grdcsd.TravelTo = (string)System.Convert.ToString(reader["TravelTo"]); grdcsd.DepartTime = (DateTime)System.Convert.ToDateTime(reader["DepartTime"]); grdcsd.ReturnDate = (DateTime)Convert.ToDateTime(reader["ReturnDate"]); grdcsd.CabinClassTravelers = (string)System.Convert.ToString(reader["CabinClassTravelers"]);
csd.Add(grdcsd); }
reader.Close(); return csd; } }
finally { SqlCn.Close(); } } } No i got the error on this implementation please help to resolve on this error