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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie DataReader Question - WEB

Status
Not open for further replies.

jpfo

Programmer
Feb 11, 2002
6
0
0
PT
Hi all!
I've a Web User Control with 4 Link Buttons, that will be a custumized menu interface. This way the user can have 0,1,2,3 or 4 all present Menu shorcuts (the way this is made is not the issue here).
My problem is that i must know how many menus he have select, and show then in each link button. I think i'm close to it, but no text is show in each button... Can anyone help me. I'am using SQL7. Tks in advance.

Code:
		private void Pop_Atalhos()
		{		
			hypPref1.Text=&quot;< Empty Slot >&quot;;
			hypPref2.Text=&quot;< Empty Slot >&quot;;
			hypPref3.Text=&quot;< Empty Slot >&quot;;
			hypPref4.Text=&quot;< Empty Slot >&quot;;
			SqlConnection conn= new SqlConnection (Application[&quot;SQLString&quot;].ToString());
			SqlDataReader dr;
			try
			{
				SqlCommand cmd = new SqlCommand ();
				cmd.CommandTimeout= 60;
				cmd.Connection= conn;
				cmd.CommandType=CommandType.Text;
				cmd.CommandText=&quot;SELECT Count(*) FROM TAB_Acessos WHERE &quot; +
					&quot;Utilizador='&quot; + Application[&quot;UserLog&quot;].ToString() + 
					&quot;' and Personalizacao='Y'&quot;;
				conn.Open();
				if (conn.State==ConnectionState.Open)
				{
					object objCount = cmd.ExecuteScalar();
					int iCount = (int) objCount;
					cmd.CommandText=&quot;Select (Menu + ' - ' + Sub) as Hyp &quot; +
						&quot;from TAB_Acessos where Utilizador='&quot; +
						Application[&quot;UserLog&quot;].ToString()+ &quot;' and &quot; +
						&quot;Personalizacao='Y' order by Menu,Sub&quot;;
					dr=cmd.ExecuteReader();
					while (dr.Read())
					if (iCount>0)
					{ 
						hypPref1.Text =dr.GetSqlString(1).ToString();
						if (iCount>1)
						{
							dr.NextResult(); 
							hypPref2.Text=dr.GetSqlString(1).ToString();
							if (iCount>2)
							{
								dr.NextResult();
								hypPref3.Text=dr.GetSqlString(1).ToString();
								if (iCount>3)
								{
									dr.NextResult();
									hypPref4.Text=dr.GetSqlString(1).ToString();
								}
							}
						}
					}
				}
			}			
			catch 
			{
				
			}
			finally
			{
				conn.Close();
			}
		}
 
Ok...sorry.. i've made a little change on my code:
Code:
hypPref1.Text =dr.GetSqlString(1).ToString();
hypPref2.Text =dr.GetSqlString(1).ToString();
hypPref3.Text =dr.GetSqlString(1).ToString();
hypPref4.Text =dr.GetSqlString(1).ToString();
must be,
Code:
hypPref1.Text =dr.GetSqlString(0).ToString();
hypPref2.Text =dr.GetSqlString(0).ToString();
hypPref3.Text =dr.GetSqlString(0).ToString();
hypPref4.Text =dr.GetSqlString(0).ToString();
(Didnt knew that began with 0)
This way i can get only the first text record... my problem continues... How to manage the datareader to fill my 4 hiperlinks texts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top