943,748 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1581
  • ASP.NET RSS
Sep 28th, 2008
0

Navigate records thru dataset.

Expand Post »
Hello,
Im using ASP.NET as front end and SQL Server as back-end. and i couldnt navigate the records. im not getting correct way. more over im having some doubts in the dataset also. normally im designing the dataset by picking the dataset from "Add New Items" only.

because, if i drag and drop a dataset from the toolbar, i couldnt set its properties correctly. Mainly i cant set the "data Source". So, for each and every table, the dataset named as DataSet1,DataSet2.....Like that. comming to the coding. im also having problem with navigating records. for that im using Session variables.

[ Imports System ]
[ Imports System.Data ]
[ Imports System.Data.SqlClient ]

In Page_Load..
[ Dim con as SqlConnection ]
[ Dim adp as SqlDataAdapter ]
[ Dim data as DataSet2 ]

[ If NotIsPostBack() Then ]
[ con.ConnectionString = "Data Source = ACER;Initial Catalog = Preethi;Integrated Security = True ]
[ con.Open() ]
[ data = New DataSet2 ]
[ adp = New SqlDataAdapter("Select * from emp",con) ]
[ adp.Fill(data,"emp") ]
[ Session("Recno") = 0 ]
[ TextBox1.Text = Data.Tables(0).Rows(0).Item(0) ]
[ Textbox2.Text = Data.Tables(0).Rows(0).Item(1) ]
[ End IF ]

In First Button , im giving..
[ Session("Recno") = 0 ]
[ TextBox1.Text = Data.Tables(0).Rows(Recno).Item(0) ]
[ TextBox2.Text = Data.Tables(0).Rows(Recno).Item(1) ]

In Next Button ,
[ Dim InitRec as Integer ]
[ InitRec = Session("Recno") + 1 ]
[ TextBox1.Text = Data.Tables(0).Rows(InitRec).Item(0) ]
[ TextBox2.Text = Data.Tables(0).Rows(InitRec).Item(0) ]

If i click in Next button, it shows Error, "There is no row at position 1" and " Index Out of Range".
the same for previous, if i give
[ InitRec = Session("Recno") - 1 ]
it will show,
" There is no row at position -1 "
I think , there may be some problem with my dataset. can anyone please enlighten me...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
preethi_ga is offline Offline
38 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: SiteMap navigation using asp:Button class
Next Thread in ASP.NET Forum Timeline: what is asp.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC