Я пытаюсь этот код для отображения информации из базы данных SQL. но я не могу видеть данные в gridview .. Как я могу решить ?? Также у меня нет ошибок.
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection("Server=CAN-PC; Database=SMS; UID=SA; PWD=delidana1963");
string sql = "";
sql = @"select Orginator,RecordDate, (select COUNT(TurkcellID) from SmsStore ";
// txttarih.Text = Calendar1.SelectedDate.ToString();
var tarih1 = String.Format("{0:yyyy-MM-dd hh:mm}", Calendar1.SelectedDate.Date);
var tarih2 = String.Format("{0:yyyy-MM-dd hh:mm}", Calendar2.SelectedDate.Date);
if (Calendar1.SelectedDate != null && Calendar2.SelectedDate != null)
sql += "where RecordDate between '" +tarih1 + "' and '" + tarih2 + "'";
else if (Calendar1.SelectedDate != null && Calendar2.SelectedDate == null)
sql += "where RecordDate between '" + tarih1 + "' and '" + DateTime.Now + "'";
sql += ") as toplammsj,";
sql += "(select COUNT(TurkcellID) from SmsStore where TurkcellID=1 ";
if (Calendar1.SelectedDate != null && Calendar2.SelectedDate != null)
sql += "and RecordDate between '" + tarih1 + "' and '" + tarih2+ "'";
else if (Calendar1.SelectedDate != null && Calendar2.SelectedDate == null)
sql += "and RecordDate between '" + tarih1 + "' and '" + DateTime.Now + "'";
sql += ") as giden,";
sql += " (select COUNT(TurkcellID) from SmsStore where TurkcellID=0 ";
if (Calendar1.SelectedDate != null && Calendar2.SelectedDate != null)
sql += "and RecordDate between '" + tarih1 + "' and '" + tarih2 + "'";
else if (Calendar1.SelectedDate != null && Calendar2.SelectedDate == null)
sql += "and RecordDate between '" + tarih1 + "' and '" + DateTime.Now + "'";
sql += ") as gitmeyen from SmsStore ";
if (Calendar1.SelectedDate != null && Calendar2.SelectedDate != null)
sql += "where RecordDate between '" + tarih1+ "' and '" + tarih2 + "'";
else if (Calendar1.SelectedDate != null && Calendar2.SelectedDate == null)
sql += "where RecordDate between '" + tarih1 + "' and '" + DateTime.Now + "'";
SqlDataAdapter adp = new SqlDataAdapter(sql, cnn);
DataTable dt = new DataTable();
adp.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.DataMember = "dt";
}
Пожалуйста, помогите мне об этой проблеме.
спасибо за все.