Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

GridView not displaying data even Reader object contains Rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
weird0 - 07 May 2007 18:53 GMT
The property of GridView1.HasRows is true and after assigning
GridView.DataSource=reader, it does not display any records in the
GirdView.

I am i missing out something? Here is the code:
protected void Button1_Click(object sender, EventArgs e)
   {
int AtmtransId=-1;
           if (Session["CustomerId"]!=null)

AtmtransId=DataAccessLayer.ATMManager.getATMTransactionsID(Session["CustomerId"].ToString(),AccNamesList.SelectedItem.Text);
       string Query = "SELECT atmtrans_date AS Date,atmtrans_branch
AS Branch,atmtrans_type AS Type,atmtrans_amount AS Amount FROM
ATM_Transactions WHERE atmtrans_id=@ATMTRANSID";
       SqlConnection sqlconnection = new SqlConnection(@"Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BankingDb.mdf;Integrated
Security=True;User Instance=True");
       SqlCommand cmd = new SqlCommand(Query,sqlconnection);
       cmd.Parameters.AddWithValue("@ATMTRANSID",AtmtransId);
       sqlconnection.Open();
       SqlDataReader reader=cmd.ExecuteReader();
       sqlconnection.Close();
       GridView1.DataSource=reader;
}
Mel - 07 May 2007 19:54 GMT
When using the SQLDataReader the connection must be open to access the data
> The property of GridView1.HasRows is true and after assigning
> GridView.DataSource=reader, it does not display any records in the
[quoted text clipped - 20 lines]
>        GridView1.DataSource=reader;
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.