Showing posts with label empty. Show all posts
Showing posts with label empty. Show all posts

Monday, March 19, 2012

How can you stop and cycle through a column(s) of data?

Ok, at this point I have the reader reading the tables data in a loop while it's not empty. During the gathering of each row of data, I was wondering if it was possible to do a next row once I've reached a certain column. The main users table has just the one user, but it's relationship table has a couple family members. I was hoping someone could show me how to make it so that the one user and all his related family members will print out to a label.
while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();

if (usrNmeLbl.Text == usr)
{
if (psswrdLbl.Text == pss)
{
//read the column from the reader and cast it to String as some may contain null values
usrNmeLbl.Text = reader["FirstName"].ToString() + " ";
psswrdLbl.Text = reader["LastName"].ToString() + "<br />";
psswrdLbl.Text += "Place of Birth: " + reader["BirthPlace"].ToString() + "<br />";
psswrdLbl.Text += "<img src=" + reader["Photo"].ToString() + " />" + "<br />";
Label4.Text = "Your relatives: " + "<br />";
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
}
If I grab the Relation table data again, it's not cycled to the next relative. I was hoping that it would, but it's not. So I'm wondering if there was something that could be added to the second set.
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();

Thank you in advance.I tried this:

while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();
//take the read data from the reader and display it for testing purposes
if (usrNmeLbl.Text == usr)
{
if (psswrdLbl.Text == pss)
{
//read the column from the reader and cast it to String as some may contain null values
usrNmeLbl.Text = reader["FirstName"].ToString() + " ";
psswrdLbl.Text = reader["LastName"].ToString() + "<br />";
psswrdLbl.Text += "Place of Birth: " + reader["BirthPlace"].ToString() + "<br />";
psswrdLbl.Text += "<img src=" + reader["Photo"].ToString() + " />" + "<br />";
Label4.Text = "Your relatives: " + "<br />";
while (reader.Read())
{
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString() + "<br />";
}
}

But for some reason the relationships print out multiple times rather than just until there are no more relatives in the database.|||You will most likely get a usable response by posting this question in one of the .NET forums.|||

Arnie Rowland wrote:

You will most likely get a usable response by posting this question in one of the .NET forums.

Ok, this is where I am really confused. Why does the reading of data loop all over again from the beginning? I would think that when it read the last row that then it would just exit out of the loop. Just like what's happening with the first loop with while(reader.Read()).

while (reader.Read())
{
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString() + "<br />";
}

Ok, thank you. I will try.

Friday, March 9, 2012

How can remove a row from my report if the results is empty or a n

How can remove a row from my report if the results is empty or a null?
If i have a null value , then i get a white space row in report - this is
not looking good !
Can somebody help me, please !?
Thank you!victoras wrote:
> How can remove a row from my report if the results is empty or a null?
> If i have a null value , then i get a white space row in report - this is
> not looking good !
> Can somebody help me, please !?
You need to write your SQL query to exclude that row, something like:
SELECT col1, col2 ... FROM mytable WHERE col1 IS NOT NULL
Luke|||or just use an iif statement on the row which toggles the visibility.
click the row, go to properties and visibility. choose expression
type
=iif(fields!afield.value is system.dbnull.value or fields!afield.value = "",
true, false)
basically says if your field is null or an empty string then do not show
else do show. True means don't show and false means do show.
"Luke Plant" <luke@.mailinator.com> wrote in message
news:do8hgo$9vq$1$8302bc10@.news.demon.co.uk...
> victoras wrote:
>> How can remove a row from my report if the results is empty or a null?
>> If i have a null value , then i get a white space row in report - this is
>> not looking good !
>> Can somebody help me, please !?
> You need to write your SQL query to exclude that row, something like:
> SELECT col1, col2 ... FROM mytable WHERE col1 IS NOT NULL
> Luke

Friday, February 24, 2012

how can i use "order by" with empty values

hi all.
how can i use "order by" with empty values
In SQL server, if record have empty value wills display firts, i need display empty value at last
please help me, thanks

use following query...

Select Value1, Value2,Value3 From table

Order By Case When Value1 is Null or Value1 = '' Then 1 Else 0 End, Value1