Posts

Showing posts from 2020

ngx-toastr, Toast not showing in Angular 7

 Try to import  ~ngx-toastr/toastr.css in your main... style.css of angular app . It will not be working due to a  conflict between some CSS . @import '~ngx-toastr/toastr.css';

connection through File saved on local in asp.net

 using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Text; using System.Web; using AI_Portal_Cloud.Utilities; namespace AI_Portal_Cloud.DAL {     class Connection     {         public string ConnectionString { get; set; }         public string Host { get; set; }                public Connection()         {             string ServerID = GlobalConstant.server_id;             try             {                                  //if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings.Get("Key3")) && string.IsNullOrEmpty(ServerID))                 //{                 //    ServerID = ConfigurationManager.AppSettings.Get("Key3").ToString().Trim();                 //}                 if (string.IsNullOrEmpty(ServerID))                     ServerID = "0";                 string _ServerFileName = Convert.ToString(ConfigurationManager.AppSettings.Get("key2"));                 string ODBCconne

Npgsql Helper class

 using System; using System.Collections.Generic; using System.Text; using System.Data; using Npgsql; using NpgsqlTypes; namespace AI_Portal_Cloud.DAL {     public class clsPSQLHelper : IDisposable     {         private NpgsqlConnection connection = null;         private String connectionString = "dbConnection";         private NpgsqlDataAdapter sqlData = new NpgsqlDataAdapter();         public NpgsqlCommand sqlCmd = new NpgsqlCommand();                  // {0} : IP, {1} : DB Name, {2} : userID, {3} : userPW         private String connectionFormat = "Server={0};Database={1};User Id={2};Password={3};Port={4}";         public String ConnectionString         {             set             {                 connectionString = value;             }         }         #region Constructors         public clsPSQLHelper()         {             //             // TODO: Add constructor logic here             //             string strConn = String.Format(new Connection().ConnectionS

Npgsql query and format with output parameters

  public string UploadExceldata(string json)         {             string connectionString = String.Format(new Connection().ConnectionString);             DataSet ds = new DataSet();             BaseResultData oBaseResult = new BaseResultData();             var connection = new Npgsql.NpgsqlConnection(connectionString);             try             {                                if (!(connection.State == ConnectionState.Open))                 {                     connection.Open();                 }                 //NpgsqlTransaction trans = connection.BeginTransaction();                 var command = new Npgsql.NpgsqlCommand("systemtracker_dbo.pr_create_user_from_excel_json", connection);                 command.CommandType = System.Data.CommandType.StoredProcedure;                 IDbDataAdapter dbDataAdapter = new NpgsqlDataAdapter();                 //Parameter Settings                 var parameter = command.CreateParameter();                 parameter.ParameterName =

Accessing URL from Browsers like Google ,Firefox, Edge , Explorer,opera

#region Windows API Functions Declarations //This Function is used to get Active Window Title... [System.Runtime.InteropServices.DllImport("user32.dll",CharSet=System.Runtime.InteropServices.CharSet.Auto)] public static extern int GetWindowText(IntPtr hwnd,string lpString, int cch); //This Function is used to get Handle for Active Window... [System.Runtime.InteropServices.DllImport("user32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)] private static extern IntPtr GetForegroundWindow(); //This Function is used to get Active process ID... [System.Runtime.InteropServices.DllImport("user32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)] private static extern Int32 GetWindowThreadProcessId(IntPtr hWnd,out Int32 lpdwProcessId);         #endregion    public static  Int32 GetWindowProcessID(IntPtr hwnd) { //This Function is used to get Active process ID... Int32 pid; GetWindowThreadProcess

Error while accessing Httpcontext.current.Session in DAL (Httpcontext doesnot exist) even after adding System.web

First of all Data Access layer is for accessing the data that is why it is named as data access layer but not the session access layer so try to use session value in an hierarchical manner from upper layer to lower layer by making it as a data For eg.  Session["server_id"] = "12";  /* In controller action method */ here server_id is a property stored as session now send this value from controller to BAL or your lower layer through function as  sendId(Convert.ToString(Session["server_id"])); as parameter in function and access this as a data function  sendId(string server_id) {     string my_server_id = server_id; }      

Inserting specific parameters through Npgsql rather than inserting it in single line query with all the parameters which are declared inside a PostgreSQL.

 DataSet dsdata = new DataSet();             string sqlQuery = "select * from systemtracker_dbo.sp_grp_comp_unit_data(par_p_oprtype:=" + opr_type;             sqlQuery = sqlQuery + " ,par_p_user_id:='" + user_id + "'";             sqlQuery = sqlQuery + " ,par_p_group_id:='" + group_id + "'";             sqlQuery = sqlQuery + " ,par_p_comp_id:='" + comp_id + "'";             sqlQuery = sqlQuery + " ,par_p_unit_id:='" + unit_id + "'";             sqlQuery = sqlQuery + " ,p_refcur:='t1'";             sqlQuery = sqlQuery + " );FETCH ALL IN t1;";             dbHelper = new AI_Portal_Cloud.DAL.clsPSQLHelper();             NpgsqlCommand sc = dbHelper.GetSqlQueryCommand(sqlQuery);             dsdata = dbHelper.RemovePostGresRefCursor(dbHelper.LoadDataSet(sc)); Here the Parameters are only inserted which have their values from fron

Return DataSet from Npgsql with multiple result set as Tables

clsPSQLConnectionCreator dbHelper = new clsPSQLConnectionCreator();         NpgsqlCommand sc = dbHelper.GetSqlQueryCommand("select * from systemtracker_dbo.pr_get_dataset('parameter1','parameter2','ref_cursor1','ref_cursor1','ref_cursor1','ref_cursor1','ref_cursor1','ref_cursor1','ref_cursor1','ref_cursor1');FETCH ALL IN t1; FETCH ALL IN t2;FETCH ALL IN t3;FETCH ALL IN t4;FETCH ALL IN t5;FETCH ALL IN t6;FETCH ALL IN t7;FETCH ALL IN t8;");         DataSet ds = dbHelper.LoadDataSet(sc);         return ds; GetSqlQueryCommand function in helper class which consist connection as well      public NpgsqlCommand GetSqlQueryCommand (string query)     {         return PrepareCommand(CommandType.Text, query);     }  private NpgsqlCommand PrepareCommand (CommandType commandType, string commandText)     {         if (connection == null)         {             connection = new NpgsqlConnect

FIX: the webpage might be temporarily down or it may have moved permanently error in asp.net MVC web application.

It might be possible that you have run your application before the shut down of your system and overnight something happens and its showing either IIS 502.5 error or   "This Website Can't be Reached" and err_access_denied when using google chrome. There may be many reason for this ...either you have updated your windows , you have reset the google settings or you may have not copied the project from the source to your system . The solution for this problem is to again download the project or copy the project to refill the missing dll files in your projects. Then rebuild the solution and run it.

Data not retaining in the text box coming from database on JQuery button click in asp.net Application

Most of the time what happen is we are able to write back end code to fetch data for text box to get auto filled on button click but it does not appear on front end or toggle for seconds in text box . Solution to remove this problem is to give type to button as type="button" which is very necessary.  function getReportData() {                 $.ajax({                     "url": "ReportTable.aspx/GetReport",                     "contentType": "application/json; charset=utf-8",                     "type": "POST",                     "dataType": "JSON",                     "success": function (data) {                         data = JSON.parse(data.d);                         $.each(data, function (key, val) {                             var tr = '<tr>';                             tr += '<td>' + (key + 1) + '</td>';