2025/08/30

 What is AI?

Artificial Intelligence (AI) is the ability of machines or computer systems to perform tasks that normally require human intelligence. This includes things like learning from experience, understanding language, recognizing images, making decisions, and solving problems.

AI is powered by data and algorithms. For example, when you give AI a lot of pictures of cats, it can learn to identify new pictures of cats on its own.


How is AI changing our daily lives?

AI is already part of your everyday routine, often without you realizing it. Some common examples:

  1. Smartphones & Assistants

    • Voice assistants like Siri, Alexa, or Google Assistant use AI to understand and respond to your questions.

    • Predictive text and autocorrect when you type messages.

  2. Social Media & Entertainment

    • AI decides what posts, reels, or videos you see on platforms like Instagram, TikTok, or YouTube based on your interests.

    • Netflix and Spotify recommend shows or music tailored to your taste.

  3. Shopping & Online Services

    • Amazon, Flipkart, and other platforms use AI to suggest products you might like.

    • Chatbots help answer customer service queries instantly.

  4. Healthcare

    • AI helps doctors detect diseases faster through medical imaging (like X-rays or scans).

    • Personalized health apps track your fitness, sleep, or even detect irregular heartbeats.

  5. Transportation

    • Google Maps or Uber uses AI to predict traffic, suggest the fastest routes, and match riders with drivers.

    • Self-driving cars are being tested using AI.

  6. Work & Productivity

    • Tools like ChatGPT, Grammarly, or translation apps help with writing, learning, and communication.

    • AI can automate repetitive tasks, freeing up time for more creative work.

  7. Finance

    • AI detects fraud in banking transactions.

    • Helps with stock market predictions and personal finance apps.


The Bigger Picture

AI is making our lives:

  • Easier (automation of boring/repetitive tasks),

  • Faster (instant answers, smart recommendations),

  • More personalized (tailored experiences).

But it also raises questions about privacy, job changes, and ethics, which society is still figuring out.

I. Based on Capability

  1. Narrow AI (Weak AI)

    • Definition: AI designed for a specific task. It cannot do anything outside its trained purpose.

    • Examples:

      • Siri, Alexa, Google Assistant (voice commands)

      • Netflix recommendations

      • Face unlock on phones

    👉 This is the AI we use most today.


  1. General AI (Strong AI)

    • Definition: AI that can perform any intellectual task like a human—reasoning, problem-solving, learning, creativity.

    • Examples:

      • Still a concept (not fully developed yet).

      • If built, it could think, adapt, and apply knowledge across fields like humans.


  1. Super AI (Artificial Superintelligence)

    • Definition: A stage where AI surpasses human intelligence in every field—creativity, emotions, decision-making.

    • Examples:

      • Exists only in theory/science fiction (e.g., movies like Her, Ex Machina).

      • Raises debates about control and ethics.


II. Based on Functionality

  1. Reactive Machines

    • AI that only reacts to situations, no memory.

    • Example: IBM’s Deep Blue (chess-playing computer that beat Garry Kasparov).

  2. Limited Memory

    • AI can use past data for decisions.

    • Example: Self-driving cars (learn from past driving data + surroundings).

  3. Theory of Mind (Future AI)

    • AI that understands human emotions, thoughts, and intentions.

    • Example: Still in research—robots that can “understand feelings.”

  4. Self-Aware AI (Future AI)

    • AI that has its own consciousness and awareness.

    • Example: Does not exist yet—only theoretical.


Quick Recap:

  • By capability: Narrow AI → General AI → Super AI.

  • By functionality: Reactive → Limited Memory → Theory of Mind → Self-Aware.



2017/12/05

How to find client's MAC Address in Asp.Net and C#.net

For Web Application

using System.Runtime.InteropServices;

[DllImport("Iphlpapi.dll")]
    private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
    [DllImport("Ws2_32.dll")]
    private static extern Int32 inet_addr(string ip);

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string userip = Request.UserHostAddress;
            string strClientIP = Request.UserHostAddress.ToString().Trim();
            Int32 ldest = inet_addr(strClientIP);
            Int32 lhost = inet_addr("");
            Int64 macinfo = new Int64();
            Int32 len = 6;
            int res = SendARP(ldest, 0, ref macinfo, ref len);
            string mac_src = macinfo.ToString("X");
            if (mac_src == "0")
            {
                if (userip == "127.0.0.1")
                    Response.Write("visited Localhost!");
                else
                    Response.Write("the IP from" + userip + "" + "<br>");
                return;
            }

            while (mac_src.Length < 12)
            {
                mac_src = mac_src.Insert(0, "0");
            }

            string mac_dest = "";

            for (int i = 0; i < 11; i++)
            {
                if (0 == (i % 2))
                {
                    if (i == 10)
                    {
                        mac_dest = mac_dest.Insert(0, mac_src.Substring(i, 2));
                    }
                    else
                    {
                        mac_dest = "-" + mac_dest.Insert(0, mac_src.Substring(i, 2));
                    }
                }
            }

            Response.Write("welcome" + userip + "<br>" + ",the mac address is" + mac_dest + "."

             + "<br>");
        }
        catch (Exception err)
        {
            Response.Write(err.Message);
        }
    }
-----------------------------------------------------------------------------------------------------------------------


For Window Application

public string GetMACAddress()
{
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    String sMacAddress = string.Empty;
    foreach (NetworkInterface adapter in nics)
    {
        if (sMacAddress == String.Empty)// only return MAC Address from first card 
        {
            IPInterfaceProperties properties = adapter.GetIPProperties();
            sMacAddress = adapter.GetPhysicalAddress().ToString();
        }
    } return sMacAddress;

}

2017/11/10

Use XML Data For Save in Database

CREATE PROCEDURE [dbo].[SaveData]
@MH INT,
@TxTest INT,
@ID INT,
@CreatedBy INT,
@strXML VARCHAR(MAX)
AS
BEGIN

SET NOCOUNT ON;

DECLARE @XMLDocHandle INT;

DECLARE @InvestorID INT
SET @ID=(SELECT Id FROM tbl_Test WHERE  ID=@ID)

IF(@strXML IS NOT NULL AND @strXML<>'')
BEGIN
EXEC sp_xml_preparedocument @XMLDocHandle OUTPUT, @strXML

CREATE TABLE #temp(ID INT,ClientID INT,InvID INT,Name VARCHAR(100),MaxAmount NVARCHAR(20),BankName NVARCHAR(500),
AN VARCHAR(30),Status VARCHAR(20),CreatedDate DATETIME,CreatedBy VARCHAR(10),StartDate DATETIME)

INSERT INTO #temp
SELECT ID,ClientID,@InvestorID,MName,MA,BName,AN,Status,GETDATE(),@CreatedBy,GETDATE()
FROM OPENXML (@XMLDocHandle, 'NewDataSet/Table1',2) 
WITH(
ID VARCHAR(10) 'ID',
ClientID VARCHAR(10) 'ClientID',
MN VARCHAR(100) 'MN',
MA NVARCHAR(20) 'MA',
BN NVARCHAR(500) 'BN',
ANumber VARCHAR(30) 'ANumber',
Status VARCHAR(20) 'Status',
CreatedBy VARCHAR(10) 'CliID'
)


MERGE INTO IMan IM
USING #temp T ON IM.InvestorID=T.InvID
WHEN MATCHED AND IM.InvestorID=T.InvID THEN

UPDATE SET
IM.CliID=T.ClientID,
IM.InID=T.InvestorID,
IM.MName=T.MName
WHEN NOT MATCHED  THEN
INSERT (ClID,IID,MName,MAmount,BName,ANumber,Status,CreatedDate,CreatedBy,SponsorBank,
SpCode,UCode,CompanyName,Action,DAmount,SOrRefNo,Frequency,UCancelled,CustomerAdditionalInfo,StartDate)
VALUES(T.ClientID,T.InvestorID,T.MandateName,T.MAmount,T.BName,T.ANumber,T.Status,T.CreatedDate,T.CreatedBy,
'HD','Xyz','Xyz','Xyz','Debit','Upto Max Amount',T.MName,'As and when Presented',
1,'NA',T.StartDate);

SELECT 1 'Status'
END


END

2017/09/11

ASP.NET Session States in SQL Server Mode

ASP.NET Session States in SQL Server Mode 


1. Run --> Cmd press enter
2. on DOS screen , type "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" press enter
3. type "aspnet_regsql.exe -S  Test_DB -U sa -P bajaj@123 -ssadd -sstype p" press enter

Then ASP State is in Database created.


Then Go to web application and define the session state mode in web.config

<system.web>
<sessionState mode="SQLServer" timeout="30" sqlConnectionString="Data Source=192.168.68.10; User ID=sa;Password=Test@123;" cookieless="false" />
</system.web>

2015/09/26

How to import / export excel file using open xml


Download "DocumentFormat.OpenXml.dll" from website and write following code


protected void btnimport_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = new DataTable();
            if (fu_File.PostedFile != null)
            {
                string strtimeStamp = string.Empty;
                strtimeStamp = System.DateTime.Now.Ticks.ToString();
                string fileName = Server.MapPath("~/UploadFile/") + strtimeStamp + "_" + fu_File.FileName;
                fu_File.SaveAs(fileName);
                string result = obj.GetXML(fileName);

                // Check pre-PGI Dt
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(result);
                XmlNode root = doc.FirstChild;
                //Display the contents of the child nodes.
                if (root.HasChildNodes)
                {
                    String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
                    SqlConnection con = new SqlConnection(strConnString);
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "SaveOrderList";
                    cmd.Parameters.Add("@xmlData", SqlDbType.NVarChar).Value = result;
                    cmd.Parameters.Add("@UploadedBy", SqlDbType.NVarChar).Value = 1;
                    cmd.Connection = con;
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        lblMessage.Text = "Record has been successfully inserted";
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    lblMessage.Text = "No Record has been available for insert";
                }


            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = "! Error:" + ex.Message;
        }
    }




    protected void btnexport_Click(object sender, EventArgs e)
    {
        try
        {
            SqlConnection con = new     SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
            SqlCommand cmd = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();
            cmd = new SqlCommand("GetOrderList", con);
            cmd.CommandType = CommandType.StoredProcedure;           
            da = new SqlDataAdapter(cmd);
            da.Fill(ds);
            con.Close();
            DataTable table = new DataTable();
            table = ds.Tables[0];
            obj.DataTableToExcel(table);
        }
        catch (Exception ex)
        {
            lblMessage.Text = "Error: " + ex.Message;
        }
    }





Add class 




    public class ConvertExcelToXml
    {
        /// <summary>
        ///  Read Data from selected excel file into DataTable
        /// </summary>
        /// <param name="filename">Excel File Path</param>
        /// <returns></returns>
        public DataTable ReadExcelFile(string filename)
        {
            // Initialize an instance of DataTable
            DataTable dt = new DataTable();

            try
            {
                // Use SpreadSheetDocument class of Open XML SDK to open excel file
                using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(filename, false))
                {
                    // Get Workbook Part of Spread Sheet Document
                    WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;

                    // Get all sheets in spread sheet document
                    IEnumerable<Sheet> sheetcollection = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();

                    // Get relationship Id
                    string relationshipId = sheetcollection.First().Id.Value;

                    // Get sheet1 Part of Spread Sheet Document
                    WorksheetPart worksheetPart = (WorksheetPart)spreadsheetDocument.WorkbookPart.GetPartById(relationshipId);

                    // Get Data in Excel file
                    SheetData sheetData = worksheetPart.Worksheet.Elements<SheetData>().First();
                    IEnumerable<Row> rowcollection = sheetData.Descendants<Row>();

                    if (rowcollection.Count() == 0)
                    {
                        return dt;
                    }

                    // Add columns
                    foreach (Cell cell in rowcollection.ElementAt(0))
                    {
                        string CellText = GetValueOfCell(spreadsheetDocument, cell);
                        CellText = CellText.Replace(" ", "O"); // All space of excel sheet header replaced by 'O'
                        while (true)
                        {
                            if (dt.Columns.IndexOf(CellText) >= 0)
                            {
                                CellText += "_1";
                                continue;
                            }
                            break;
                        }
                        dt.Columns.Add(CellText);
                    }
                    dt.Columns.Add("Last");
                    //foreach (Cell cell in rowcollection.ElementAt(0))
                    //{
                    //    dt.Columns.Add(GetValueOfCell(spreadsheetDocument, cell));
                    //}

                    // Add rows into DataTable
                    foreach (Row row in rowcollection)
                    {
                        DataRow temprow = dt.NewRow();
                        int columnIndex = 0;
                        foreach (Cell cell in row.Descendants<Cell>())
                        {
                            // Get Cell Column Index
                            int cellColumnIndex = GetColumnIndex(GetColumnName(cell.CellReference));

                            if (columnIndex < cellColumnIndex)
                            {
                                do
                                {
                                    temprow[columnIndex] = string.Empty;
                                    columnIndex++;
                                }

                                while (columnIndex < cellColumnIndex);
                            }

                            temprow[columnIndex] = GetValueOfCell(spreadsheetDocument, cell);
                            columnIndex++;
                        }

                        // Add the row to DataTable
                        // the rows include header row
                        dt.Rows.Add(temprow);
                    }
                }

                // Here remove header row
                dt.Rows.RemoveAt(0);
                return dt;
            }
            catch (IOException ex)
            {
                throw new IOException(ex.Message);
            }
        }

        /// <summary>
        ///  Get Value of Cell
        /// </summary>
        /// <param name="spreadsheetdocument">SpreadSheet Document Object</param>
        /// <param name="cell">Cell Object</param>
        /// <returns>The Value in Cell</returns>
        private static string GetValueOfCell(SpreadsheetDocument spreadsheetdocument, Cell cell)
        {
            // Get value in Cell
            SharedStringTablePart sharedString = spreadsheetdocument.WorkbookPart.SharedStringTablePart;
            if (cell.CellValue == null)
            {
                return string.Empty;
            }

            string cellValue = cell.CellValue.InnerText;

            // The condition that the Cell DataType is SharedString
            if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString)
            {
                return sharedString.SharedStringTable.ChildElements[int.Parse(cellValue)].InnerText;
            }
            else
            {
                return cellValue;
            }
        }

        /// <summary>
        /// Get Column Name From given cell name
        /// </summary>
        /// <param name="cellReference">Cell Name(For example,A1)</param>
        /// <returns>Column Name(For example, A)</returns>
        private string GetColumnName(string cellReference)
        {
            // Create a regular expression to match the column name of cell
            Regex regex = new Regex("[A-Za-z]+");
            Match match = regex.Match(cellReference);
            return match.Value;
        }

        /// <summary>
        /// Get Index of Column from given column name
        /// </summary>
        /// <param name="columnName">Column Name(For Example,A or AA)</param>
        /// <returns>Column Index</returns>
        private int GetColumnIndex(string colName)
        {
            string columnName = colName.ToLowerInvariant();
            int columnIndex = 0;
            //int factor = 1;

            //// From right to left
            //for (int position = columnName.Length - 1; position >= 0; position--)
            //{
            //    // For letters
            //    if (Char.IsLetter(columnName[position]))
            //    {
            //        columnIndex += factor * ((columnName[position] - 'A') + 1) - 1;
            //        factor *= 26;
            //    }
            //}
            string s = "abcdefghijklmnopqrstuvwxyz";
            if (columnName.Length == 1)
            {
                columnIndex = s.IndexOf(columnName);
            }
            else
            {
                char[] parts = new char[] { columnName[0], columnName[1] };
                columnIndex = s.IndexOf(parts[0]);
                columnIndex += (26 * (s.IndexOf(parts[0]) + 1) + s.IndexOf(parts[1]));
            }
            return columnIndex;
        }

        /// <summary>
        /// Convert DataTable to Xml format
        /// </summary>
        /// <param name="filename">Excel File Path</param>
        /// <returns>Xml format string</returns>
        public string GetXML(string filename)
        {
            try
            {
                DataTable dt = new DataTable();
                dt = this.ReadExcelFile(filename);
                int ColIndex = dt.Columns.IndexOf("pre-PGIODt");
                dt.Rows.Cast<DataRow>().Where(r => Convert.ToString(r.ItemArray[ColIndex]).Length == 0).ToList().ForEach(r => r.Delete());// Delete Blank Rows (QC is empty);
                DataTable dtMain = dt.DefaultView.ToTable(false, "Plnt", "SalesODoc.", "NameO1", "CustomerOpurchaseOorderOno", "Description", "OOOrderOqty", "Delivery", "Ac.GIOdate", "pre-PGIODt", "OOOOOOWBSOElement");

                using (DataSet ds = new DataSet())
                {
                    ds.Tables.Add(dtMain);
                    return ds.GetXml();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// convert datatable into excel file.
        /// </summary>
        /// <param name="dt"></param>
        public void DataTableToExcel(DataTable dt)
        {
            DataView dataView = ConvertToDataView(dt);
            string theString = string.Empty;
            ASCIIEncoding objEncoding = null;
            HttpResponse objHttpResponse = null;
            int i = 0;
            objHttpResponse = HttpContext.Current.Response;
            objHttpResponse.Clear();
            objHttpResponse.AddHeader("Content-Disposition", ("attachment;filename=" + "SLIRequest.xls"));
            objHttpResponse.ContentType = "application/ms-excel";

            if ((dataView != null) && (dataView.Table.Rows.Count > 0))
            {
                theString = ConvertDataViewToString(dataView, "", "\t");
                theString = theString.Replace('"', ' ');
            }
            if (theString.Length <= 0)
            {
                theString = "Data not found.";
            }
            objEncoding = new ASCIIEncoding();
            i = objEncoding.GetByteCount(theString);
            objHttpResponse.AddHeader("Content-Length", i.ToString());
            objHttpResponse.BinaryWrite(objEncoding.GetBytes(theString));
            objHttpResponse.Charset = "";
            objHttpResponse.End();

        }
        /// <summary>
        /// convert datatable to dataview
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        DataView ConvertToDataView(DataTable dt)
        {
            DataView dv = new DataView(dt);
            return dv;
        }

        /// <summary>
        /// convert dataview to string
        /// </summary>
        /// <param name="srcDataView"></param>
        /// <param name="Delimiter"></param>
        /// <param name="Separator"></param>
        /// <returns></returns>
        public static string ConvertDataViewToString(DataView srcDataView, string Delimiter, string Separator)
        {
            StringBuilder objStringBuilder = new StringBuilder();
            objStringBuilder.Length = 0;

            foreach (DataColumn column in srcDataView.Table.Columns)
            {
                if ((Delimiter != null) && (Delimiter.Trim().Length > 0))
                {
                    objStringBuilder.Append(Delimiter);
                }
                objStringBuilder.Append(column.ColumnName);
                if ((Delimiter != null) && (Delimiter.Trim().Length > 0))
                {
                    objStringBuilder.Append(Delimiter);
                }
                objStringBuilder.Append(Separator);
            }
            if (objStringBuilder.Length > Separator.Trim().Length)
            {
                objStringBuilder.Length -= Separator.Trim().Length;
            }
            objStringBuilder.Append(Environment.NewLine);
            foreach (DataRowView theDataRowView in srcDataView)
            {
                foreach (DataColumn theDataColumn2 in srcDataView.Table.Columns)
                {
                    if ((Delimiter != null) && (Delimiter.Trim().Length > 0))
                    {
                        objStringBuilder.Append(Delimiter);
                    }
                    objStringBuilder.Append(RuntimeHelpers.GetObjectValue(theDataRowView[theDataColumn2.ColumnName]));
                    if ((Delimiter != null) && (Delimiter.Trim().Length > 0))
                    {
                        objStringBuilder.Append(Delimiter);
                    }
                    objStringBuilder.Append(Separator);
                }
                objStringBuilder.Length--;
                objStringBuilder.Append("\r\n");
            }
            if (objStringBuilder != null)
            {
                return objStringBuilder.ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }

 What is AI? Artificial Intelligence (AI) is the ability of machines or computer systems to perform tasks that normally require human intell...