本文介绍了如何从数据集中获取一个字符串中的单列多个记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此数据集中有emailid列表:

  public   string  get_emailid( string  circle)
{
string str2 = 从user_中选择emailid,其中circle =' + circle + '和role = 3;
SqlCommand cmd = new SqlCommand(str2,connection);
SqlDataAdapter da = new SqlDataAdapter(cmd );
DataSet ds = new DataSet();
da.Fill(ds);
string str = ds.Tables [0] .Rows [0] [
emailid ]。ToString();
return str;
}



返回以下电子邮件:

gandhi@gmail.com

chauhan@yahoo.com

kohli2@gmail.com



所以,当我使用SqlDataAd在aspx页面上调用此函数时apter da并存储在一个名为email的字符串中,我希望在另一个函数中使用此字符串电子邮件3次:

  string  email = da.get_emailid(Circle); 





我如何在一个字符串电子邮件中获得这3封电子邮件?



我尝试了什么:



i不想使用ArrayList list = new ArrayList();,我希望它使用for循环。我不知道......

解决方案

I have emailid list in this dataset:

public string get_emailid(string circle)
{
string str2 = "select emailid from user_ where circle='" + circle + "' and role=3;
SqlCommand cmd = new SqlCommand(str2, connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
string str = ds.Tables[0].Rows[0]["emailid"].ToString();
return str;
}


that returns below emails:
gandhi@gmail.com
chauhan@yahoo.com
kohli2@gmail.com

so, when i call this function on aspx page like this using SqlDataAdapter da and store in the one string named email, and i want use this string email 3 times in another function:

string email= da.get_emailid(Circle);



how can i get this 3 emailid in one string email?

What I have tried:

i dont want to use ArrayList list = new ArrayList();, i want it using for loop. I have no idea...

解决方案


这篇关于如何从数据集中获取一个字符串中的单列多个记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 11:08