Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Practical No : 10
- Aim : Demonstrates using the binding attribute of an endpoint element in WCF.
- Input :
- Default.aspx:-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- public partial class _Default : System.Web.UI.Page
- {
- SqlConnection con;
- SqlCommand cmd;
- SqlDataAdapter da;
- DataTable dt;
- String str;
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- str = ConfigurationManager.ConnectionStrings["strcon"].ConnectionString;
- con = new SqlConnection(str);
- con.Open();
- String a, b, c;
- a = TextBox1.Text;
- b = TextBox2.Text;
- c = TextBox3.Text;
- cmd = new SqlCommand("insert into employee(ename,sal,dept)values('" + a + "','" + b + "','" + c + "')", con);
- cmd.ExecuteNonQuery();
- TextBox1.Text = "";
- TextBox2.Text = "";
- TextBox3.Text = "";
- Label4.Text = "Record Saved succcessfully....";
- da=new SqlDataAdapter("select * from employee",con);
- dt=new DataTable();
- da.Fill(dt);
- GridView1.DataSource = dt;
- GridView1.DataBind();
- con.Close();
- }
- catch (Exception ex) { }
- }
- protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- }
- Web config:-
- <?xml version="1.0"?>
- <!--
- For more information on how to configure your ASP.NET application, please visit
- http://go.microsoft.com/fwlink/?LinkId=169433
- -->
- <configuration>
- <system.web>
- <compilation debug="true" targetFramework="4.0"/>
- </system.web>
- <connectionStrings>
- <add name="strcon" connectionString="Data Source=(local);Initial Catalog=db1;Integrated Security=True"/>
- </connectionStrings>
- </configuration>
Add Comment
Please, Sign In to add comment