在asp.net中检测到无法访问的代码,而放在控制台一切正常
public string item(int i){
SqlConnection con = new SqlConnection(str_con);
con.Open();
string str_sql = "select item_text from item where item_id='"+i+"'";
SqlCommand com = new SqlCommand(str_sql,con);
SqlDataReader read = com.ExecuteReader(CommandBehavior.CloseConnection);
read.Read();
if (read.HasRows)
{
string str=((string)read["Item_text"]).Trim(); 字符串输出正常
string[] str_array = str.Split('%');
for (int k = 0;k < str_array.Length; k++) 错误提示k++无法访问的代码
{
string str_Split = str_array[k];
return str_Split;
}
}
con.Close();
return null;
}