blogspot visit counter

Monday, 28 October 2013

Json with integer in php

Json with integer in php
Introduction :-
Here i am explain how to use  PHP  json_encode function.

In some cases numeric data may  appear as numeric strings, for example 1 as "1". While consuming the json data on a client app that would mean an extra parsing to get for example an int from the string.

The solution is to simply use an extra option (JSON_NUMERIC_CHECK) on the json_encode function call:

then you will not get the data in string format.You get the data like 1 without double quotes

use for json_encode
   



<?php echo json_encode($data, JSON_NUMERIC_CHECK); ?>

For example

{"data":[{"x":0,"y":0,"username":"%s","gender":"%s","location":"%s","id":"%s","age":30},{"x":0,"y":0,"username":"Ranvijay Singh","gender":"male","location":"Navi Mumbai (New Mumbai), India","id":1179445904,"age":30},{"x":10,"y":20,"username":"aman","gender":"male","location":"indore","id":123,"age":30}]}


Here x and y is integer values then not show double quotes

Thursday, 24 October 2013

How to Change Table Name in MySQL

Introduction :-
If you want to change the Table name without loss you data then it's very simple to change the table in MySQL database and sql server database.

Description : -

To change the name of an existing table first to second, use this command as shown below


RENAME TABLE first TO second;

For Example

You have table name like stodent_tab
and there are four fields like First_name,Last_Name,Stud_ID,Stud_Batch
and you want to change the name of  stodent_tab because you have done mistake in student_tab name

So Query Like This


RENAME TABLE stodent_tab TO student_tab;

Note -: This query is same if you want to use the sql server database.

Monday, 21 October 2013

What are the core components of .NET framework

What are the core components of .NET framework

Categories :- Benefits of net frameworkHR interview question and answer , 1-year-exp-asp.net interview question and answer , Interview questions and answers for 2 years , C# interview Question And Answer

 The Two Components of .NET Framework are
 1) Common Language Run time [CLR]
2)  .Net Framework class Library

 Other key components of .NET Framework:

NET Framework Class Library

  3)   Dynamic Language Runtimes (DLR)
   4 ) Application Domains
   5)  Runtime Host
   6)  Common Type System
   7)  Metadata and Self-Describing Components
    8) Cross-Language Interoperability
    9) NET Framework Security
    10) Profiling
    Side-by-Side Execution

Briefly describe MSIL

.Net Framework is shipped with compilers of all programming languages to develop programs. There are separate compilers for the visual basic,C#, and visual c++ programming languages in .Net Framework.Each .Net compiler produces code after compiling the source code. The intermediate code is common for all languages and is understandable only to .NET environment. This intermediate is know as MSIL.

MSIL file is executable file that can transferred various machines. Therefore, it is said that MSIL file are portable to nay machine.

Monday, 14 October 2013

What are the benefits of net framework

What are the benefits of net framework
.Net framework offers many benefits to application developers.some of this benefits are as follow :

 1) Consistent programming model :- 
 Dot net framework provide consistent object oriented  programming model across various language.You can use the model  to create a program s for performing different task, such as connecting to and retrieving data from database and reading from and writing to files.

Saturday, 12 October 2013

How to get xml data into grid view in asp.net

How to get xml data into grid view
Introduction :- In this article i have explain how to show XML file data in asp.net grid-view .

Description :- In  my previous post i have explained How to Generating XML file From MySQL database 
Create and read XML file in asp.net , Read data from XML file in asp.net , now i have explain how to show XML file data in grid view  using   asp.net

Step 1 :- Create a new asp.net web site.
Step 2:- Add a new page in your project and give the name to the page gridxml.aspx..
Step 3 :- Add  one xml file and write something like this which you want to show on gridview page of asp.net as show below.

Note  - This is a Employees.xml file already exist in your project.


<?xml version="1.0" standalone="yes"?>
<Employees>
  <Employee>
    <EmployeeID>Chitranjan</EmployeeID>
    <CompanyName>abc informatics</CompanyName>
    <ContactName>chintu </ContactName>
    <ContactTitle>Developer</ContactTitle>
    <Address>ganraj</Address>
    <City>Indore</City>
    <PostalCode>452001</PostalCode>
    <Country>India</Country>
    <Phone>00000000</Phone>
    <Fax>4545499</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Aman</EmployeeID>
    <CompanyName>Y N Info</CompanyName>
    <ContactName>Aman</ContactName>
    <ContactTitle>Artiest</ContactTitle>
    <Address>Boriwali east</Address>
    <City>Pune</City>
    <PostalCode>3436</PostalCode>
    <Country>India</Country>
    <Phone>9549544345</Phone>
    <Fax>559935</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Rahul</EmployeeID>
    <CompanyName>Gold Main</CompanyName>
    <ContactName>Hot</ContactName>
    <ContactTitle>Designer</ContactTitle>
    <Address>dfdf</Address>
    <City>bBombay</City>
    <PostalCode>5434546</PostalCode>
    <Country>India</Country>
    <Phone>54545</Phone>
  </Employee>
  <Employee>
    <EmployeeID>Ronak</EmployeeID>
    <CompanyName>Yeswant Niwas</CompanyName>
    <ContactName>Golo</ContactName>
    <ContactTitle>Producer</ContactTitle>
    <Address>345 Alock Nagar</Address>
    <City>Bhopal</City>
    <PostalCode>554677</PostalCode>
    <Country>India</Country>
    <Phone>5656</Phone>
    <Fax>0909ASD</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Ravi</EmployeeID>
    <CompanyName>DFF</CompanyName>
    <ContactName>LJ</ContactName>
    <ContactTitle>PPOIU</ContactTitle>
    <Address>79879 JKJK</Address>
    <City>ABC</City>
    <PostalCode>6656DF</PostalCode>
    <Country>RFF</Country>
    <Phone>54554FGGG</Phone>
    <Fax>GGG555</Fax>
  </Employee>
  <Employee>
    <EmployeeID>JJ8</EmployeeID>
    <CompanyName>HJKGJ8</CompanyName>
    <ContactName>GGH55</ContactName>
    <ContactTitle>New Dehli</ContactTitle>
    <Address>Rambag</Address>
    <City>ASD</City>
    <PostalCode>87GG</PostalCode>
    <Country>India</Country>
    <Phone>7667654</Phone>
    <Fax>FGH45</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Sumit</EmployeeID>
    <CompanyName>Sumo tech</CompanyName>
    <ContactName>Sumo</ContactName>
    <ContactTitle>Manager</ContactTitle>
    <Address>656 FFH</Address>
    <City>Strasbourg</City>
    <PostalCode>8788</PostalCode>
    <Country>Noida</Country>
    <Phone>665-778-545</Phone>
    <Fax>545.54.55</Fax>
  </Employee>
 
</Employees>

 Step 4 :- open the gridxml.aspx file and write the code as show below.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class CS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.BindGrid();
        }
    }

    private void BindGrid()
    {
        using (DataSet ds = new DataSet())
        {
            ds.ReadXml(Server.MapPath("~/Employees.xml"));
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }

    protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.BindGrid();
    }
}

Note -: Source code also available in vb.net

Download sample code attached



Sunday, 6 October 2013

Generating Xml file From Mysql database

Generating XML FILE From MySQL database
Introduction :- In this article i have explain how to  generate  XML  File   from mysql database in asp.net .

Description :- In my previous article i have explain Crete and read XML file in asp.net   and  read data from XML file in asp.net . Now i am explain how to generate  XML file in  asp.net.



Step 1 :- Create table  for generate xml file using mysql database. Table structure as show below


CREATE TABLE `user_tab` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `User_Name` varchar(50) DEFAULT NULL,
  `Contact_No` varchar(50) DEFAULT NULL,
  `Donet_Values` float DEFAULT NULL,
  `Donate_Date` datetime DEFAULT NULL,
  `User_Email` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`ID`)
)

GUI table structure as show below


Step 2:- create a new asp.net web  application and add  new page and write this code on web page as show below


//generat xml file and save in folder
    protected void Button1_Click(object sender, EventArgs e)
    {
        MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=database Name;password=Your Password;Pooling=false;");
        con.Open();
        string str = "select * from slider_tab1 ";
        MySqlDataAdapter da = new MySqlDataAdapter(str,con);
        DataSet ds = new DataSet();
        da.Fill(ds,"Userinfo");
        ds.WriteXml(Server.MapPath("~/xmlfile/xml_file.xml"));
        lblmsg.Text = "XML File Created Successfully";
      
    }

Explanation -: Here i take a new asp.net web page and drag and drop  a asp.net button and one label for show the message file is created and write this code on asp.net button click event.

In this code i  have selected  all the data from mysql  database and create a object of mysql DataAdapter and create DaSet and fill all the DataAdapter values in Dataset and save the file in xml format in  xmlfile folder

Note- If you use mysql database then use the mysql to asp.net connector for connect the MySQL database to asp.net
Related Posts Plugin for WordPress, Blogger...