Tuesday, 23 December 2014

Show image in data controls from the database

  • Hello...friends today I will show you that how to display image in data controls like that datalist,repeater.
  • First We make data table. Name:- images      Field Name:- image, name.
  • And now we take a control like as Repeater control.
  • We are take itemtemplet tag in repeater.
  • And then you can put image and label control in itemtemplet tag. Let we see it.
  • We write this code in repeater control's Source code.

<asp:Repeater ID="Repeater1" runat="server">

 <ItemTemplate>

  <table class="auto-style1">

   <tr>

    <td>

     <asp:Image ID="Image1" runat="server" Width="150px" Height="100" ImageUrl='<%#Eval("image") %>'/>

    </td>

   </tr>

   <tr>

    <td class="auto-style4">

     <asp:Label ID="Label1" runat="server" Text='<%#Eval("name") %>'></asp:Label>

    </td>

   </tr>

  </table>

 </ItemTemplate>

</asp:Repeater>

Get Full Example



  • After then We write code of displaying image from DB.
  • We write a namespace.
using System.Data.SqlClient; //use this in namespace in both version.

using System.Data; //not requerd to use this namespace in Visual Studo 2008.

  • We write an Object.
SqlConnection conn = new SqlConnection(@"path of the database/query string "); //for create a connection.

SqlCommand cmd; //interecting with the database means take the action in database like ad insert, update, delete. no required in log in program.

SqlDataAdapter adp; // read the data from the database. ,always take this object wheneve establist the connection

DataTable dt;
  • We write a displaying code in page load Object.
conn.Open();adp = new SqlDataAdapter("select * from imgupload", conn); dt = new DataTable();
dt = new DataTable();
adp.Fill(dt);
Repeater1.DataSource=dt;
Repeater1.DataBind();
conn.Close();

  • Now Your Program is ready to run.

if You any Query in php or get Example of php click on :- PHP EXAMLE

Sunday, 14 December 2014

Uploading image in database and store in folder

  • Today I will show you that how to Upload Image in web application in ASP.NET to Use Visual Studio 2008 OR 2012.
  • Create table 'photo' in database. Field name:- images, img_name. 
  • We can create many tables in one database.
  • First We required some control like that textbox, fileupload, and button. And you have to make new folder in your web application
  • Now we take two namespace.
    using System.Data.SqlClient; //use this in namespace in both version.



    using System.Data; //not requerd to use this namespace in Visual Studo 2008.
Now in the class we write the connection object and other objects for Upload Image

    SqlConnection conn = new SqlConnection(@"path of the database/query string ");  //for create a connection.
    SqlCommand cmd; //interecting with the database means take the action in database like ad insert, update, delete. no required in log in program.
    SqlDataAdapter adp; // read the data from the database. ,always take this object wheneve establist the connection
     
    DataTable dt;


  • Now we write code in Upload button. 
  • If You want to only upload image, you write only this code.


    string str3 = "~/imgfolder/" + FileUpload3.FileName; // add folder name which is make in your webapplication


    FileUpload3.SaveAs(Server.MapPath(str3));

  • Or else Upload Image With add in database. You Write this code.
    conn.Open();    string str3 = "~/imges3/" + FileUpload3.FileName;
    FileUpload3.SaveAs(Server.MapPath(str3));    cmd = new SqlCommand("insert into dt values('" + str3 + "','" + TextBox1.text + "')", conn);
    cmd.ExecuteNonQuery();
    conn.Close();
 

Now Your Web application is ready to run.

GET FULL EXAMPLE

if You any Query in php or get Example of php click on :- PHP EXAMLE

Create Database Connection with Sql Server 2012 & 2008

  • First is that, we have to create a new database in website.
  • After add new table in that database.
  • Now let we make login, insert Update and Delete action form using connected & disconnected architecture.
  • Now we have required some control like that textbox, button, label, required Field validation controls.
  • Now we see the code view.
  • We have to put two namespace in code view.( in Visual Studio 2012.One already put in Visual Studio 2008).

     using System.Data.SqlClient; //use this in namespace in both version.


     using System.Data; //not requerd to use this namespace in Visual Studo 2008.


  • Now in the class we write the connection object and other objects for login

    SqlConnection conn = new SqlConnection(@"path of the database/query string ");  //for create a connection.


    SqlCommand cmd; //interecting with the database means take the action in database like ad insert, update, delete. no required in log in program.


    SqlDataAdapter adp; // read the data from the database. ,always take this object wheneve establist the connection
   

    DataTable dt;



  • We write code for login Query.

   conn.Open();
   adp = new SqlDataAdapter("select * from Login where usnm='" + TextBox1.Text + "'and pwd='" + TextBox2.Text + "'", conn);

   dt = new DataTable();

   adp.Fill(dt);


   if (dt.Rows.Count > 0)
   {   Session["user"] = TextBox1.Text;
   Response.Redirect("Home.aspx");
  }
else{Label1.Visible = true;
}
conn.Close();



  • We write code for insert Query.
   cmd = new SqlCommand("insert into employ values('" + TextBox1.Text + "','" + TextBox2.Text + "')",conn);

   adp = new SqlDataAdapter("select * from purche",conn);

   dt = new DataTable();

   adp.Fill(dt);
   cmd.ExecuteNonQuery();
   conn.Close();

  • We Write Query for Update Query.
   cmd = new SqlCommand("update employ set empname='"+TextBox1.Text+"',empadd='"+TextBox2.Text+"' where empid='"+TextBox3.Text+"')",conn);


  • We Write Query for Delete Query.
   cmd = new SqlCommand("delete from employ where empid='"+TextBox3.Text+"')",conn);

GET FULL EXAMPLE

if You any Query in php or get Example of php click on :- PHP EXAMLE


Tuesday, 2 December 2014

Create Database with SQL server 2012 & 2008

Hi. Friends today we will see that how to create database in visual studio 2012 or 2008 of asp.net C# and how to add table in that database

steps :-
  • First one is that we have to create a new web site in the visual studio 2012 or visual studio 2008.Its easy to create just go to File --> New --> Web site OR shortcut key is that SIFT+ALT+N.
  • Open Solution Explorer and right click on our website folder and select Add and in this select Add New Item or shortcut key is that  CLRT+SHIFT+A. 
  • And now You get the pop up menu and you have to select SQL Server Database and you have to see that its extension is .mdf                 
  • And click on the OK button and now your database is ready to us Open Server Explorer and Refresh it. After then right click on the Tables, Select Add New Table.
  • Now we see data table we have to fill field and data type and in the code view you have to change table name. And click on Update button (in Visual Studio 2012). 
  •  After click on Update database( in Visual Studio 2012). 
  • And if you want to add data in data table right click on table and show user data and fill the data and don't save it just close this tab( in Visual Studio 2012).  
  • And in 2008.Save the data table in the database to press CTRL+S and give a table name (in Visual Studio 2008). 
  • And if you want to add data in data table right click on table and show user data and fill the data and save it (in Visual Studio 2008).

if You any Query in php or get Example of php click on :- PHP EXAMLE

Show image in data controls from the database

Hello...friends today I will show you that how to display image in data controls like that datalist,repeater. First We make data table. N...