ADO.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 50
Number of posts: 63

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Showing dataset's Current Record in Datagrid, Posted by digitalsindh on 12 Mar 2010 at 2:23 AM
Friends I m workin on vb.net ado.net oledb, I have also added datagrid Control to my form

for retriving database from .Mdb file i used following code

'decleared Name Space
Imports System.Data.OleDb


'Dicleared Variabls in Class Form1

Dim con As New OleDb.OleDbConnection

Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim inc As Integer
Dim MaxRows As Integer


'created Navigate Records() 'class
txtSno.Text = ds.Tables("SLAPhonebook").Rows(inc).Item("SNo")
txtName.Text = ds.Tables("SLAPhonebook").Rows(inc).Item("Name")
txtLastName.Text = ds.Tables("SLAPhonebook").Rows(inc).Item("LastName")
txtOrganization.Text = ds.Tables("SLAPhonebook").Rows(inc).Item("Organization")
' and so on...

' on form load () event i put following coding
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SLAPhonebook.mdb"
sql = "Select * From sla"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "SLAPhonebook")
MaxRows = ds.Tables("SLAPhonebook").Rows.Count
inc = -1


' here i connected all text boxes to '0' row of ds.tables(rows) to show first row, as follows


txtSno.Text = ds.Tables("SLAPhonebook").Rows(0).Item("SNo")
txtName.Text = ds.Tables("SLAPhonebook").Rows(0).Item("Name")
txtLastName.Text = ds.Tables("SLAPhonebook").Rows(0).Item("LastName")


'here in formload event i also binded data grid with dataset
DataGrid1.SetDataBinding(ds, "sla")
DataGrid1.DataSource = ds.Tables(0)



'friends every thing is working fine, but when i click to move next record in table, it moves but only in text boxes which i connected with dataset.tables(rows), i want to datagrid to also move to next record as soon as i press next record button

' I used following code for "next Record Button", to move on next record

if inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("No More Rows")

End If

DataGrid1.DataSource = ds.Tables(inc)
DataGrid1.SetDataBinding(ds, "sla")


Please Help My with My Question how to move current record in datagrid, i mean when i press Next record button then datagrid's data (table) also should move to next record


or when i click any record in datagrid, then the current record of dataset also should move to clicked record of datagrid, so that i also may see datagrid's clicked record in textboxes

in short i want to use default feature of vb6's ado control, when we bind datagrid with ado control, it worked autometically, both data grid and adodc wer connected each other at a time, so that moving next record also apears in datagrid. please help me in my question, i m new to .net i need ur help




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.