我在从数据库表中接收列值时应用了split函数。我想在button_click
事件期间继续这个过程。
这是我的c#代码。
protected void Button2_Click(object sender, EventArgs e)
{
string st = "SELECT F_L FROM split_master";
cmd = new SqlCommand(st, sqlcon);
int count = 0;
string[] word = st.Split();
for (count = 0; count <= word.Length - 1; count++)
{
MessageBox.Show(word[count]);
}
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
请帮忙。
答案 0 :(得分:0)
试试这段代码:
protected void Button2_Click(object sender, EventArgs e)
{
string st = "SELECT F_L FROM split_master";
cmd = new SqlCommand(st, sqlcon);
cmd.Connection.Open();
SqlDataReader sqlread = cmd.ExecuteReader();
cmd.Connection.Close();
while(sqlread.Read()){
string[] word = sqlread["F_L"].ToString().Split();
for (int count = 0; count <= word.Length; count++)
{
MessageBox.Show(word[count]);
}
}
}