preethi_ga 0 Light Poster

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.