Navigate records thru dataset.

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 38
Reputation: preethi_ga is an unknown quantity at this point 
Solved Threads: 0
preethi_ga preethi_ga is offline Offline
Light Poster

Navigate records thru dataset.

 
0
  #1
Sep 28th, 2008
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...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC