c#中请教一个arraylist 用法
publicstring[]HelloWorld(stringprefixText,intcount){SqlConnectioncon=newSqlConnection...
public string[] HelloWorld(string prefixText, int count)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString ());
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand cmd = new SqlCommand("select top " + count + " name from revise where name like \'" + prefixText + "%\'", con);
SqlDataReader dr = cmd.ExecuteReader();
ArrayList s = new ArrayList();
while (dr.Read())
s.Add(dr[0].ToString());
return (string )s.ToArray();//这一行是错的,应该怎么写才是对的了
} 展开
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString ());
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand cmd = new SqlCommand("select top " + count + " name from revise where name like \'" + prefixText + "%\'", con);
SqlDataReader dr = cmd.ExecuteReader();
ArrayList s = new ArrayList();
while (dr.Read())
s.Add(dr[0].ToString());
return (string )s.ToArray();//这一行是错的,应该怎么写才是对的了
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询