Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

public string[] 1

Status
Not open for further replies.

jamert

Programmer
Dec 9, 2007
80
CA
Hi i'm wondering 2 things
[1]
can one loop thru a public string array (aller)

if (aller[0].ToString() != Request.Form["aller0"].ToString()) { cmd.Parameters.Add("@aller0", SqlDbType.NVarChar).Value = Request.Form["aller0"].ToString(); }

if (aller[1].ToString() != Request.Form["aller1"].ToString()) { cmd.Parameters.Add("@aller1", SqlDbType.NVarChar).Value = Request.Form["aller1"].ToString(); }

if (aller[2].ToString() != Request.Form["aller2"].ToString()) {
....


something like ?:

for (int i = 0; i <= 26; i++)
{

if (aller.ToString() != Request.Form["aller"].ToString()) { cmd.Parameters.Add("@aller", SqlDbType.NVarChar).Value = Request.Form["aller"].ToString()); }

}

[2]
ALSO can using the SqlDataReader rdr be used with the public array something like,

aller = (string)rdr1["aller"];

Thanks again
 
Code:
for (int i = 0; i <= 26; i++)
{
 string column = string.Format("aller{0}", i);
 if (aller[i].ToString() != Request.Form[[b]column[/b]].ToString()) 
 { 
  cmd.Parameters.Add("@" + [b]column[/b], SqlDbType.NVarChar).Value = Request.Form[[b]column[/b]].ToString()); 
 }
}

untested, ymmv.


mr s. <;)

 
Thanks misterstick will try it.

Any thoughts on reusing the SqlDataReader "rdr" in a loop something like:

for (int i = 0; i <= 26; i++)
{
string column = string.Format(rdr1["aller{0}"], i);

if (column.Length>0)
{
aller = column;
}

}

Thanks
 
that assigns the name of a column as its value.

or

aller[1] = "aller1";

is that what you want?

mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top