Saturday, April 30, 2011

How To Create Databse in MySql for PHP

Simple steps for creating the database in MySql for PHP.Just follow the below steps.

1.Start the wamp server and then select the localhost from wamp server pop menu as shown in below figure or just type the http://locahost/ .


2.After selecting localhost or typing http://localhost you'll get the home page of the PHP as shown in figure.



3.Select the phpmyadmin from the Tools and you will get the phpmyadmin home page.

4. Write down the your database name and click on create as shown below.


5.After clicking on the create button you will get the new window in which you will have to enter the Table name and number of columns in the table as shown in figure.Enter the Table Nameand Column Name and click on the GO.


6.After clicking the GO you will get the screen in which you will have to enter the all information of each and every column(column name,data type and size).
Sample is given below.

Field Type Length/Values
ID INT
Name VARCHAR 30
Mobile_No DECIMAL 10,0

7.Rules for the field name.
  1. Field name should be start with a-z,A-Z or _.
  2. Field name should not be start with 0-9 or any other special character like @,#,$.
  3. Field name should not be a any reserved words of the mysql like int,varchar,decimal etc...
  4. If the data type of the field are INT,TINYINT,BIGINT,DATE,DATETIME,then there is no need to give a size.Just leave the Length/Values column blank for those field as shown in the example for the ID field.
  5. If the data type of the field is the DECIMAL, then enter the size as shown in example.Digits before point,digits after point.
  6. If you want to define any field as Primary key then select the primary key radio button on the right side.
8. After inserting details of all the field the just click on the Save.

9.After clicking on the Save button your data base is ready to use with PHP page.

I'll explain you how to use database in the PHP page in the next BLOG.

If you like this blog and helpful to you then leave the comment for this blog that will help me to continue with BLOG .Waiting for response.

Also let me know in case of you have any problem in creating the database using these steps.

Saturday, March 5, 2011

Stored Procedure In Asp.net

1.Add using Syste.Data.SqlClient namespace.

2.Create a connection string for that.
Right click on your database(in server emplorer) and properties.
Copy the connection string property of database.

3.In your code right SqlConnection con=new SqlConnection(@"copy connection string here");

4.Now create a command
SqlCommand cmd=new ("StoredProcedureName",con);

5.Set commandtype of cmd
cmd.CommandType=CommandType.StoredProcedure;

6.Add the parameter one by one
For example My stored procedure accepts two parameter name and address then pass as follows:
cmd.Parameters.add(new parameters("@name",SqlDbType.Varchar,size).value=textbox1.text;
cmd.Parameters.add(new parameters("@address",SqlDbType.Varchar,size).value=textbox2.text;

6.Now Open the connection by con.Open();

7.Execute the command by cmd.ExecuteNonQuery();

8.Close the connection by con.close();

Friday, October 22, 2010

જે કશું જ જાણતો નથી અને એ પણ નથી જાણતો

જે કશું જ જાણતો નથી અને એ પણ નથી જાણતો
કે એ કશું જ જાણતો નથી એ મૂર્ખ છે – છોડો એને !
જે કશું જ જાણતો નથી અને જાણે છે કે એ
કશું જ જાણતો નથી એ સામાન્ય છે – શીખવો એને !
જે કંઈક જાણે છે પણ એને જાણ નથી કે
તે જાણે છે તે નિદ્રામાં છે – જગાડો તેને !
જે જ્ઞાની છે અને તેના જ્ઞાન વિષે સભાન છે
તે શાણો છે – અનુસરો એને !

દુ:ખી થવાના દસ રસ્તા

(ક) તમારી જ વાત કર્યા કરો
(ખ) તમારો જ વિચાર કર્યા કરો.
(ગ) ‘કદર’ ‘કદર’ ઝંખ્યા કરો.
(ઘ) કોઈ તમારી ઉપેક્ષા કરે તો બળ્યા કરો.
(ચ) કોઈનો યે વિશ્વાસ ન કરો.
(છ) તમારી ફરજમાંથી શક્ય ત્યાં સુધી છટકી જાવ.
(જ) બને તેટલી વાર ‘હું’ શબ્દનો ઉપયોગ કરો.
(ઝ) બીજા માટે બને તેટલું ઓછું કરો.
(ટ) તમારી મહેરબાની બદલ લોકો આભાર ન માને તો સમસમ્યા કરો.
(ઠ) દરેક બાબતમાં તમારો જ કક્કો ઘૂંટ્યા કરો.

Saturday, September 11, 2010

How to connect linq to sql:-

1.Add New Item -->LINQ to SQL classes
It will create 3 files in App_Code Folder
1.Whatever you name created.dbml
2.Whatever you name created.dbml.layout
3.Whatever you name created.dbml.cs
2.Open .dbml file
It will totally blank with two part.
3.Drag and drop all the tables in the dbml file.
When you drop tables it will automatically create relationship between tables as per primary key and foreign key.
4.Now you are ready to use linq to sql

First create the object of that lind class
Suppose name is HotelDb then create object as shown
HotelDbDataContext obj=new HotelDbDataContext();
It will by default attach DataContext with class name.
Now all the table names converted in the plural(Bahuvachan)
e.g. City become cities etc.
Now to select all the data from table
Griedview1.datasource=obj.tablename in plural(It will display in dropdown)
Griedview.databind();

Wednesday, April 7, 2010

Difference Between two Dates in asp.net

There are two textbox in which there are dates:
Following c# coding will calculate days between these two date and will display in Label.



DateTime dt1=Convert.toDateTime(TextBox1.text);

DateTime dt2=Convert.toDateTime(TextBox2.text);
TimeSpan ts=dt2.Substract(dt1);
Label1.text=ts.days.toString();