nikkkilll

practical10

Oct 4th, 2019
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. Practical No : 10
  2. Aim : Demonstrates using the binding attribute of an endpoint element in WCF.
  3.  
  4. Input :
  5.  
  6. Default.aspx:-
  7.  
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Web;
  12. using System.Web.UI;
  13. using System.Web.UI.WebControls;
  14. using System.Data;
  15. using System.Data.SqlClient;
  16. using System.Configuration;
  17.  
  18. public partial class _Default : System.Web.UI.Page
  19. {
  20. SqlConnection con;
  21. SqlCommand cmd;
  22. SqlDataAdapter da;
  23. DataTable dt;
  24. String str;
  25. protected void Page_Load(object sender, EventArgs e)
  26. {
  27.  
  28. }
  29. protected void TextBox1_TextChanged(object sender, EventArgs e)
  30. {
  31.  
  32. }
  33.  
  34. protected void Button1_Click(object sender, EventArgs e)
  35. {
  36. try
  37. {
  38. str = ConfigurationManager.ConnectionStrings["strcon"].ConnectionString;
  39. con = new SqlConnection(str);
  40. con.Open();
  41. String a, b, c;
  42. a = TextBox1.Text;
  43. b = TextBox2.Text;
  44. c = TextBox3.Text;
  45. cmd = new SqlCommand("insert into employee(ename,sal,dept)values('" + a + "','" + b + "','" + c + "')", con);
  46. cmd.ExecuteNonQuery();
  47. TextBox1.Text = "";
  48. TextBox2.Text = "";
  49. TextBox3.Text = "";
  50. Label4.Text = "Record Saved succcessfully....";
  51.  
  52. da=new SqlDataAdapter("select * from employee",con);
  53. dt=new DataTable();
  54. da.Fill(dt);
  55. GridView1.DataSource = dt;
  56. GridView1.DataBind();
  57.  
  58. con.Close();
  59.  
  60. }
  61. catch (Exception ex) { }
  62. }
  63. protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
  64. {
  65.  
  66. }
  67. }
  68.  
  69.  
  70. Web config:-
  71. <?xml version="1.0"?>
  72. <!--
  73. For more information on how to configure your ASP.NET application, please visit
  74. http://go.microsoft.com/fwlink/?LinkId=169433
  75. -->
  76. <configuration>
  77. <system.web>
  78. <compilation debug="true" targetFramework="4.0"/>
  79. </system.web>
  80.  
  81. <connectionStrings>
  82. <add name="strcon" connectionString="Data Source=(local);Initial Catalog=db1;Integrated Security=True"/>
  83. </connectionStrings>
  84. </configuration>
Add Comment
Please, Sign In to add comment