User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2007
Posts: 6
Reputation: kishorJagtap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kishorJagtap kishorJagtap is offline Offline
Newbie Poster

I want next record to Display

  #1  
Aug 1st, 2007
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 .
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 712
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 97
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: I want next record to Display

  #2  
Aug 1st, 2007
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
Reply With Quote  
Join Date: Aug 2007
Posts: 6
Reputation: kishorJagtap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kishorJagtap kishorJagtap is offline Offline
Newbie Poster

Re: I want next record to Display

  #3  
Aug 1st, 2007
Originally Posted by QVeen72 View Post
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
Reply With Quote  
Join Date: Aug 2007
Posts: 6
Reputation: kishorJagtap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kishorJagtap kishorJagtap is offline Offline
Newbie Poster

as per your suggestion

  #4  
Aug 1st, 2007
Originally Posted by QVeen72 View Post
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
Reply With Quote  
Join Date: Nov 2006
Posts: 712
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 97
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: I want next record to Display

  #5  
Aug 2nd, 2007
Hi,

what line u r getting the error...?


Regards
Veena
Reply With Quote  
Join Date: Aug 2006
Location: India
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Rep Power: 4
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: I want next record to Display

  #6  
Aug 2nd, 2007
Why don't you insert some break points and cycle through your code using F10 or F11 and tell us which part your getting the error.
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
Reply With Quote  
Join Date: Nov 2006
Posts: 712
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 97
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: I want next record to Display

  #7  
Aug 2nd, 2007
hello,

as i said, declare all teh variables
Form-LEVEL

Means on the top of form.. u have declared in Page Load...
and Put the inc=inc+1 outside the if Condition

REgards
Veena
Reply With Quote  
Join Date: Aug 2007
Posts: 6
Reputation: kishorJagtap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kishorJagtap kishorJagtap is offline Offline
Newbie Poster

Re: I want next record to Display

  #8  
Aug 2nd, 2007
I have done it it shows error when i Press Button Click . At the time the records we want to display on text box it gives Error as " Object reference not set to an instance of an object."
Reply With Quote  
Join Date: Aug 2006
Location: India
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Rep Power: 4
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: I want next record to Display

  #9  
Aug 2nd, 2007
what did you declare inc as? Did you try my suggestion as which line your getting the error?.

Show us which part of the line your getting error?
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
Reply With Quote  
Join Date: Aug 2006
Location: India
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Rep Power: 4
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: I want next record to Display

  #10  
Aug 2nd, 2007
Try using the databindings in the textbox

  1. 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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 4:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC