Hi miss786,
in while loop you are calling "return", so in first time only it will return the current url and go out of the loop, so it will not enter into loop again. that's why , you are not getting 3 values.
Also, if want to return 3 values than return type of the method should be a string array or list or if its string then it should be concatenated with some delimiters.
Below is solution to your problem,
1. string array or list
public static string[] storyURLSF()
{
string article = "";
string[] articles = new string[3];
int count = 0;
ArrayList alArticles = new ArrayList();
int publication = 0;
int issue = 0;
int storyid = 0;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["##"].ConnectionString);
string commandtext = "#####";
SqlCommand command = new SqlCommand(commandtext, con);
con.Open();
command.Parameters.Add(new SqlParameter("title", article));
command.Parameters.Add(new SqlParameter("PUBLICATION_ID", publication));
command.Parameters.Add(new SqlParameter("ISSUE_ID", issue));
command.Parameters.Add(new SqlParameter("STORYID", storyid));
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string name = reader.GetString(0);
int pub = reader.GetInt32(1);
int iss = reader.GetInt32(2);
int sid = reader.GetInt32(3);
string str = Convert.ToString(pub);
string iss1 = Convert.ToString(iss);
string sid1 = Convert.ToString(sid);
var builder = new UriBuilder("http://www.structuredcreditinvestor.com/Article.asp?");
builder.Port = -1;
var query = HttpUtility.ParseQueryString(builder.Query);
query["article"] = name;
query["ISS"] = str;
query["PUB"] = iss1;
query["SID"] = sid1;
builder.Query = query.ToString();
string url = builder.ToString();
articles[count] = url;
count ++;
alArticles.Add(url);
}
return articles;
return alArticles;
}
if you want string return type, then append each url by a delimiter and spilt it for individual values.
Thanks,
Prateek