I am creating a project in which i want to group the words dynamically previously i Split and grouped them as static
if i need to insert (1 100000888888888 4949494949 17032 HYB DR 25-May-2000 Booked 05-May-2000)
OUTPUT 1) 1 2)100000888888888 3)4949494949 4)17032 5)HYB 6)DR 7)5-May-2000 8)Booked 9)05-May-2000
my cs code for this was
string text;
string sr = "";
string transid = "";
string pnr = "";
string trainno = "";
string fr = "";
string tt = "";
string doj = "";
string reservestat = "";
string dobook = "";
text = txtarea.Text;
string[] words = text.Split('\n');
foreach (string s1 in words)
{
string text1 = s1;
string[] words1 = text1.Split('\t');
int a = words1.Length;
if (a == 9 || a == 10)
{
if (a == 9)
{
sr = words1[1].ToString();
transid = words1[2].ToString();
pnr = words1[3].ToString();
trainno = words1[4].ToString();
fr = words1[5].ToString();
SqlCommand cmd1 = new SqlCommand("SpLocZonedata");// select location from zonedata
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Connection = con;
SqlParameter param1;
param1 = new SqlParameter("@location_code", fr);
param1.Direction = ParameterDirection.Input;
param1.DbType = DbType.String;
cmd1.Parameters.Add(param1);
con.Open();
SqlDataReader da0 = cmd1.ExecuteReader();
if (da0.Read())
{
Label5.Text = da0["location_name"].ToString();
}
con.Close();
tt = words1[6].ToString();
SqlCommand cmd2 = new SqlCommand("SpLocZonedata");//sellect location from zonedata
cmd2.CommandType = CommandType.StoredProcedure;
SqlParameter param ;
param = new SqlParameter("@location_code", tt);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
cmd2.Parameters.Add(param);
cmd2.Connection = con;
con.Open();
SqlDataReader tt1 = cmd2.ExecuteReader();
if (tt1.Read())
{
Label6.Text = tt1["location_name"].ToString();
}
con.Close();
doj = words1[7].ToString();
reservestat = words1[8].ToString();
dobook = words1[9].ToString();
} but now the values from user are inserting like
(1 1 000008 88888888 494949 4949 170 32 HYB DR 25-May-2000 Booked 05-May-2000) but the output must be same
1) 1 2)100000888888888 3)4949494949 4)17032 5)HYB 6)DR 7)5-May-2000 8)Booked 9)05-May-2000