Advertisement
Milotronik

WebService

Jun 7th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.45 KB | None | 0 0
  1.     [WebMethod]
  2.     public DataSet consultarEmpleadosPubs()
  3.     {
  4.  
  5.         String urlConexion = "Data Source=(local);AttachDbFilename='X:\\UTN\\2.2\\Laboratorio4\\Acceso a Datos\\PUBS.MDF';Integrated Security=True";
  6.         SqlConnection conexion = new SqlConnection(urlConexion);
  7.         SqlDataAdapter consulta = new SqlDataAdapter("SELECT * FROM employee", conexion);
  8.         DataSet datos = new DataSet();
  9.         consulta.Fill(datos);
  10.  
  11.         return datos;
  12.     }
  13.  
  14. /////////////////////////////////////////////////////////////////
  15. Este es el aspx q llama al consultarEmleadosPubs o el North...
  16. /////////////////////////////////////////////////////////////////
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Web;
  21. using System.Web.UI;
  22. using System.Web.UI.WebControls;
  23. using System.Data.SqlClient;
  24. using System.Data;
  25.  
  26. public partial class _Default : System.Web.UI.Page
  27. {
  28.     protected void Page_Load(object sender, EventArgs e)
  29.     {
  30.  
  31.     }
  32.    
  33.     protected void Button1_Click(object sender, EventArgs e)
  34.     {
  35.         WebService sw = new WebService();
  36.         if (DropDownList1.SelectedValue == "DBNorthwind") //lee Northwind
  37.         {
  38.             GridView1.DataSource = sw.consultarEmpleadosNorthwind();
  39.             GridView1.DataBind();
  40.         }
  41.         else //lee Pubs
  42.         {
  43.             GridView1.DataSource = sw.consultarEmpleadosPubs();
  44.             GridView1.DataBind();
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement