I am applying a split function when receiving a column value from a database table. And I want to proceed this process while button_click event. but there is a problem the string is not showing in Console.Writeline Method. here is my code:
protected void Button2_Click(object sender, EventArgs e)
{
string st = "SELECT F_L FROM split_master where First_name='" + TextBox1.Text + "' ";
cmd = new SqlCommand(st, sqlcon);
cmd.Connection.Open();
SqlDataReader sqlread = cmd.ExecuteReader();
while (sqlread.Read())
{
string[] word = sqlread["F_L"].ToString().Split();
for (int count = 0; count < word.Length; count++)
foreach(string words in word)
{
Console.WriteLine(word[count]);
}
}
cmd.Connection.Close();
}
and i also want to split a string on spaces. please help .