Hi friends,
i am using Visual web developer to design the website. In my website i have a multiline textbox. i want to give 10 input values in the multiline textbox and display the database records in the gridview. But the last record only printed in the gridview. I have used 2 tables namely Sinmain and Tranship.can u clear my doubts? Thanx to u all.
csharp
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Text;
using System.Drawing;
public partial class TrackingDet : System.Web.UI.Page
{
//protected System.Web.UI.HtmlControls.HtmlGenericControl frame1;
//HtmlControl frame1 = (HtmlControl)this.FindControl("frame1");
//frame1.attr
protected void Page_Load(object sender, EventArgs e)
{
String strcnno = Session["username"].ToString(); ;
//cnno = cnno.Trim();
Char[] chDelims = new Char[] { '\n','\r' };
String[] cnnoarr = strcnno.Split(chDelims,StringSplitOptions.RemoveEmptyEntries);
//while (x < cnnoarr.Length )
//{
//String cnno = cnnoarr[0]; String cnno1 = cnnoarr[2];
//String cnno2 = cnnoarr[4];
//String cnno3 = cnnoarr[6]; String cnno4 = cnnoarr[8];
//String cnno5 = cnnoarr[10]; String cnno6 = cnnoarr[12];
//String cnno7 = cnnoarr[14]; String cnno8 = cnnoarr[16];
//String cnno9 = cnnoarr[18];
//while (i <= 10)
//{
foreach (String strArr in cnnoarr)
{
if (!IsPostBack)
{
int recCount = 0;
String StrCon = "Server=www.*******.com; DataBase=******; uid=******; pwd=*****;Asynchronous Processing=true";
SqlConnection Conn = new SqlConnection(StrCon);
SqlDataAdapter Dap = new SqlDataAdapter();
//SqlDataAdapter Dap1 = new SqlDataAdapter();
String StrSql = "SELECT Count(*) FROM firstflight.TRANSHIP" +
" WHERE (CNNO ='" + strArr + "') ";
DataSet ds = new DataSet();
//DataSet ds1 = new DataSet();
SqlCommand cmd1 = new SqlCommand(StrSql, Conn);
cmd1.Connection.Open();
recCount = (int)cmd1.ExecuteScalar();
if (recCount == 0)
{
String StrSqlS = "SELECT Count(*) FROM firstflight.SINMAIN" +
" WHERE (CNNO ='" + strArr + "')";
SqlCommand cmdS = new SqlCommand(StrSqlS, Conn);
cmd1.Connection.Close();
cmdS.Connection.Open();
recCount = (int)cmdS.ExecuteScalar();
String StrSqlS1 = "SELECT CNNO, CONVERT (varchar(20), BOOKDATE, 103) AS recddate, COUNTRY as destn, REFNO, DELDATE, DELTIME, SIGN, REMARKS FROM firstflight.SINMAIN" +
" WHERE (CNNO ='" + strArr + "')";
cmdS.Connection.Close();
SqlCommand cmdS1 = new SqlCommand(StrSqlS1, Conn);
cmd1.Connection.Close();
cmdS1.Connection.Open();
Dap.SelectCommand = cmdS1;
Dap.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
cmdS1.Connection.Close();
}
else
{
String StrSqlT = "SELECT CNNO, REFNO, CONVERT (varchar(20), RECDDATE, 103) AS RECDDATE, DESTN , DELDATE , DELTIME , SIGN, REMARKS FROM firstflight.TRANSHIP" +
" WHERE (CNNO ='" + strArr + "')";
SqlCommand cmdT = new SqlCommand(StrSqlT, Conn);
cmd1.Connection.Close();
cmdT.Connection.Open();
Dap.SelectCommand = cmdT;
Dap.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
cmdT.Connection.Close();
}
}
}
}
}