I used this code to retrive from one record to another first tried to retrive the first record.................
varible decalaration
Imports System.Data
Imports System.Data.SqlClient
Public Class Form3
'
Dim connectionstring As String = Module1.connectionString
Dim sqlconn As New SqlConnection(connectionstring)
Public sqlDataset As New DataSet
Dim da1 As OleDb.OleDbDataAdapter
Dim myCommand1 As SqlCommand
Public SQLdr As SqlDataReader
Dim myConnection As SqlConnection
Dim nxtmajor As String
Dim sqlcmd As New SqlCommand
'Dim dep As String
Dim tbStudent As DataTable
Public n As Integer
Public i As Integer
'Dim sname As String
Public majorname As String
Dim myCommand As SqlCommand
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
myCommand = New SqlCommand("SELECT * FROM Major ", myConnection)
Dim da As SqlDataAdapter
SQLdr = myCommand.ExecuteReader()
da = New SqlDataAdapter(myCommand)
da.Fill(sqlDataset, "Vb_table")
myConnection.Close()
End Sub
Private Sub nav()
TextBox1.Text = sqlDataset.Tables("Vb_table").Rows(i).Item(1)
TextBox2.Text = sqlDataset.Tables("Vb_table").Rows(i).Item(2)
TextBox3.Text = sqlDataset.Tables("Vb_table").Rows(i).Item(3)
End Sub
Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFirst.Click
i = 0
nav()
End Sub
I got the error pointing :TextBox1.Text = sqlDataset.Tables("Vb_table").Rows(i).Item(1)
error:Object reference not set to an instance of an object.