I have created one webpage in ASP.net C# front end and Oracle 11g back end. Webpage consist of one ASP calendar, two DropDownList and one GridView. As per the selection of date and DropDownList, data will show in GridView. But when i select the any combination data is not showing in grid view. However, when i write same query in database through sqldeveloper i.e. SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '24-06-15%'; data retrieve from database.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
OracleConnection con = new OracleConnection("Data Source=10.31.41.103/ORCL;User ID=RL_PET;Password=RL_PET;Unicode=True");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
Label1.Visible = false;
if (DropDownList1.Text == "Store In" && DropDownList2.Text == "ALL")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '"+ Calendar1.SelectedDate.Date+"%' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
else if (DropDownList1.Text == "Store In")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '" + Calendar1.SelectedDate.Date+"%' AND SHIFT = '" + DropDownList2.Text + "' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
}
}