Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after filling dataset then also it shows old values in dataset.
This problem arises sometimes but after uploading web.config it shows proper data in dataset.
Site working fine on old iis but when we shifted it to iis 7 this problem started.

please answer me as soon as possible thanks in advance

not just on one page on every page it gives error because it is giving some weird data and not taking data from given sql.
code:

C#
       SqlConnection con1 = new SqlConnection("connction" );
        DataSet temp = new DataSet();
        SqlCommand temp1 = new SqlCommand();
        SqlDataAdapter temp2;
        ds = new DataSet();
        int bcnt = 0, rcnt = 0;
        ds = null;
        ds = new DataSet(); string col = string.Empty;
        temp1 = new SqlCommand("select image, linkto, desiredwidth from ( select image, linkto, desiredwidth from pbdetail, userbanner where pbdetail.userbannerid=userbanner.userbannerid and pagebannerid=1 and disp=1 and (pbdetail.awaiting =0 or pbdetail.awaiting is null) union select image, linkto, desiredwidth from pbdetail where pbdetail.userbannerid=0 and pagebannerid=1 and disp=1 and (pbdetail.awaiting =0 or pbdetail.awaiting is null) )q1 order by newid() ", con1);
        temp2 = new SqlDataAdapter(temp1);
        temp2.Fill(temp);
 if (temp.Tables[0].Rows.Count > 0)
        {
for (int i = 0; i <= rcnt; i++)
            {

                string x = "banner" + i.ToString();
                Image banner = (Image)FindControl(x);
                string str = ds.Tables[0].Rows[i]["image"].ToString();//error on this line image column not exist
                if (str.StartsWith("u") == true)
                {
                    banner.ImageUrl = ds.Tables[0].Rows[i]["image"].ToString();
                }
                else
                {
                    banner.ImageUrl = "uploads/" + ds.Tables[0].Rows[i]["image"].ToString();
                }
                HtmlAnchor linkto = (HtmlAnchor)FindControl("linkto" + i.ToString());
                linkto.HRef = "http://" + ds.Tables[0].Rows[i]["linkto"].ToString() + "";
               
            }
}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 11-Apr-13 23:24pm
v7
Comments
Prasad Khandekar 12-Apr-13 1:34am    
Are you using some sort of caching?
harshada3 12-Apr-13 1:51am    
no nothing it just simple selecting records
Shubham Choudhary 12-Apr-13 2:30am    
hi!! harshada3..
i think its not a problem of iis you should try to clear the dataset before loading data on it
harshada3 12-Apr-13 2:33am    
i am taking new dataset so there is no need to clear it
Can you show us the code ?

1 solution

You are looping through rcnt which is initialized to 0. You are not setting any value for rcnt. You need to cross check it and see why it is not assigned. The value of rcnt will be 0 always. You might be forgetting to set the value for rcnt. Debug your code and check it.


--Amit
 
Share this answer
 
Comments
_Amy 12-Apr-13 5:06am    
Why downvoted? Any reason?
harshada3 12-Apr-13 5:26am    
that not the problem i just missed statement of initialization
_Amy 12-Apr-13 5:29am    
You should give a proper code block. Anyway, did you tried checking the value for ds.Tables[0].Rows[i]["image"].ToString()? Put a breakpoint and debug the code. Check for the value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900