•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 423,015 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,005 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1926 | Replies: 11
![]() |
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Dim conn As New SqlConnection(connstr1)
Dim sql As String
sql = "Select * from address1"
'Dim da As SqlDataAdapter
Dim cmd As New SqlCommand(sql, conn)
conn.Open()
Dim ds As New DataSet()
da = New SqlDataAdapter(sql, conn)
da.Fill(ds, "Address1")
maxrows = ds.Tables("Address1").Rows.Count
inc = -1
conn.Close()
'If next_record <= maxrows - 1 Then
If inc <> maxrows - 1 Then
inc = inc + 1
'NavigateRecords()
TextBox1.Text = ds.Tables("address1").Rows(inc).Item("rollno").ToString
TextBox2.Text = ds.Tables("address1").Rows(inc).Item("name").ToString
'inc = inc + 1
End If
I am new in vb.net .
I want next record when i Click on Next button Each time .
I am using Vb.net & sql server 2005 as a back end .
please help me .
Dim sql As String
sql = "Select * from address1"
'Dim da As SqlDataAdapter
Dim cmd As New SqlCommand(sql, conn)
conn.Open()
Dim ds As New DataSet()
da = New SqlDataAdapter(sql, conn)
da.Fill(ds, "Address1")
maxrows = ds.Tables("Address1").Rows.Count
inc = -1
conn.Close()
'If next_record <= maxrows - 1 Then
If inc <> maxrows - 1 Then
inc = inc + 1
'NavigateRecords()
TextBox1.Text = ds.Tables("address1").Rows(inc).Item("rollno").ToString
TextBox2.Text = ds.Tables("address1").Rows(inc).Item("name").ToString
'inc = inc + 1
End If
I am new in vb.net .
I want next record when i Click on Next button Each time .
I am using Vb.net & sql server 2005 as a back end .
please help me .
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Hi,
Code is all OK, Open the Connection In FormLoad. and Write the Population of textbox in CmdNext_Click event..
Declare all the Variables FormLevel.
REgards
Veena
I have done as per your suggestion .
But it Gives error as follows "Object reference not set to an instance of an object."
Changed code is as
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Dim conn As New SqlConnection(connstr1)
'Dim sql As String
'sql = "Select * from address1"
'Dim da As SqlDataAdapter
'Dim cmd As New SqlCommand(sql, conn)
'conn.Open()
'Dim ds As New DataSet()
'da = New SqlDataAdapter(sql, conn)
'da.Fill(ds, "Address1")
'maxrows = ds.Tables("Address1").Rows.Count
'inc = -1
'conn.Close()
'If next_record <= maxrows - 1 Then
If inc <> maxrows - 1 Then
inc = inc + 1
'NavigateRecords()
TextBox1.Text = ds.Tables("address1").Rows(inc).Item("rollno").ToString
TextBox2.Text = ds.Tables("address1").Rows(inc).Item("name").ToString
'inc = inc + 1
End If
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\AddressBook.mdb"
connstr1 = "server=kishorjagtap;uid=sa;pwd=kishor;database=addressbook"
Dim conn As New SqlConnection(connstr1)
Dim sql As String
sql = "Select * from address1"
Dim cmd As New SqlCommand(sql, conn)
conn.Open()
Dim ds As New DataSet()
da = New SqlDataAdapter(sql, conn)
da.Fill(ds, "Address1")
maxrows = ds.Tables("Address1").Rows.Count
inc = -1
conn.Close()
End Sub
•
•
Join Date: Aug 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Hi,
Code is all OK, Open the Connection In FormLoad. and Write the Population of textbox in CmdNext_Click event..
Declare all the Variables FormLevel.
REgards
Veena
I have done as per your suggestion .
But it Gives error as follows "Object reference not set to an instance of an object."
Changed code is as
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Dim conn As New SqlConnection(connstr1)
'Dim sql As String
'sql = "Select * from address1"
'Dim da As SqlDataAdapter
'Dim cmd As New SqlCommand(sql, conn)
'conn.Open()
'Dim ds As New DataSet()
'da = New SqlDataAdapter(sql, conn)
'da.Fill(ds, "Address1")
'maxrows = ds.Tables("Address1").Rows.Count
'inc = -1
'conn.Close()
'If next_record <= maxrows - 1 Then
If inc <> maxrows - 1 Then
inc = inc + 1
'NavigateRecords()
TextBox1.Text = ds.Tables("address1").Rows(inc).Item("rollno").ToString
TextBox2.Text = ds.Tables("address1").Rows(inc).Item("name").ToString
'inc = inc + 1
End If
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\AddressBook.mdb"
connstr1 = "server=kishorjagtap;uid=sa;pwd=kishor;database=addressbook"
Dim conn As New SqlConnection(connstr1)
Dim sql As String
sql = "Select * from address1"
Dim cmd As New SqlCommand(sql, conn)
conn.Open()
Dim ds As New DataSet()
da = New SqlDataAdapter(sql, conn)
da.Fill(ds, "Address1")
maxrows = ds.Tables("Address1").Rows.Count
inc = -1
conn.Close()
End Sub
Try using the databindings in the textbox
vb Syntax (Toggle Plain Text)
Textbox1.DataBindings.Add("Text", ds.Address1, "rollno")
Last edited by arjunsasidharan : Aug 2nd, 2007 at 8:53 am.
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
One is as though nothing is a miracle.
The other is as if everything is.
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- USB in DOS (Peripherals)
- I want next record to Display (VB.NET)
- how to get to next record on click of a button. (JavaScript / DHTML / AJAX)
- Command text was not set for the command object. (ASP)
- Crystal 9 question (Computer Science and Software Design)
- Unique field/primary key for Access (Visual Basic 4 / 5 / 6)
- random-access files (C++)
- Please Help!!! MOD function (ASP)
Other Threads in the VB.NET Forum
- Previous Thread: how to search
- Next Thread: text to speech in different languages


Linear Mode