using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Logmein
{
/// <summary>
/// Summary description for Flightdetails.
/// </summary>
public class Flightdetails : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Image Image5;
private void Page_Load(object sender, System.EventArgs e)
{
{
SqlConnection conn = new SqlConnection("workstation id=RIKESH;packet size=4096;user id=sa;data source=RIKESH;persist security info=False;initial catalog=FlyWaySystem");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM FlightInformation ", conn);
DataSet ds = new DataSet();
da.Fill (ds);
DropDownList1.DataSource = ds;
DropDownList1.DataValueField = "Origin";
DropDownList1.DataBind () ;
string selectedText1=DropDownList1.SelectedItem.Text;
DropDownList2.DataSource = ds;
DropDownList2.DataValueField = "Destination";
DropDownList2.DataBind () ;
string selectedText2=DropDownList2.SelectedItem.Text;
}
if (Session["update"]==null)
{
Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection sqlconn;
SqlCommand sqlcomm;
sqlconn = new SqlConnection("workstation id=RIKESH;packet size=4096;user id=sa;data source=RIKESH;persist security info=False;initial catalog=FlyWaySystem");
sqlconn.Open();
sqlcomm = new SqlCommand();
sqlcomm.Connection = sqlconn;
//Here I am definied command type is Stored Procedure.
sqlcomm.CommandType = CommandType.StoredProcedure;
//Here I mentioned the Stored Procedure Name.
sqlcomm.CommandText = "Searchflights";
//Here I fix the variable values to Stored Procedure Parameters. You can easily understand if you can see the Stored Procedure Code.
sqlcomm.Parameters.Add("@origin", SqlDbType.NVarChar);
sqlcomm.Parameters["@origin"].Value = DropDownList1.SelectedItem.ToString();
sqlcomm.Parameters.Add("@destination", SqlDbType.NVarChar);
sqlcomm.Parameters["@destination"].Value = DropDownList2.SelectedItem.ToString();
sqlcomm.ExecuteNonQuery();
SqlDataReader rdr = sqlcomm.ExecuteReader();
//checking whether data reader contains any row.
if (rdr.HasRows)
{
}
sqlcomm.Dispose();
sqlconn.Close();
}
}
}
http://cdn.dreaminco.../helpsmilie.gif

New Topic/Question
Reply




MultiQuote






|