472,330 Members | 1,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

Navigation through records with NEXT, PREVIOUS, LAST, FIRST buttons

Hi all,

I have a windows form which contains several text boxes. I would like
these text boxes to DataBind to records in an Access.mdb. I have connected
to the Access.mdb using ADO.Net.

When I click on a navigation button, it doesn't matter which navigation
button, the text boxes are not updated to show the new navigated record. I
have included the code I'm using below. I have removed all code I'm sure
does not affect the DataBinding process and I have only left the code for
the MOVE_NEXT button. WHEN THE FULL LISTING IS COMPILED THERE ARE NO
ERRORS.

Any help as to why its not updating correctly will be much appreciated.

Kind regards,
Jon.
-------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace ClientInfo.cs
{

public CurrencyManager currManager;
public DataSet myDSet;
public OleDbDataAdapter myDAdapter;

public frmClientInfo()
{
InitializeComponent();
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=A:\
ClientInfo.mdb";

OleDbConnection myConn = new OleDbConnection(strConn);
myDSet = new DataSet();
myConn.Open();
myDAdapter = new OleDbDataAdapter("SELECT * FROM ClientInfo", myConn);
myDAdapter.Fill(myDSet,"ClientInfo");
Bind();
currManager = (CurrencyManager)this.BindingContext[myDSet.Tables
["ClientInfo"]];

static void Main()
{
Application.Run(new frmClientInfo());
}

public void btnViewNext_Click(object sender, System.EventArgs e)
{
this.currManager.Position += 1;
}
public void Bind()
{
txtName.DataBindings.Add("Text", myDSet, "ClientInfo.Name");
txtAddress1.DataBindings.Add("Text", myDSet, "ClientInfo.Address1");
txtAddress2.DataBindings.Add("Text", myDSet, "ClientInfo.Address2");
txtAddress3.DataBindings.Add("Text", myDSet, "ClientInfo.Address3");
txtAddress4.DataBindings.Add("Text", myDSet, "ClientInfo.Address4");
txtPostcode.DataBindings.Add("Text", myDSet, "ClientInfo.Postcode");

txtPrimaryContactNo.DataBindings.Add("Text", myDSet,
"ClientInfo.PrimaryNo");

txtSecondaryContactNo.DataBindings.Add("Text", myDSet,
"ClientInfo.SecondaryNo");

txtEmail.DataBindings.Add("Text", myDSet, "ClientInfo.Email");
}
}
}
-------------------------------------------------------------------------

--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
1 9570
insted of currManager = (CurrencyManager)this.BindingContext[myDSet.Tables
["ClientInfo"]];
try
currManager = (CurrencyManager)this.BindingContext[myDSet, "ClientInfo"];

"Jon Smith via DotNetMonster.com" wrote:
Hi all,

I have a windows form which contains several text boxes. I would like
these text boxes to DataBind to records in an Access.mdb. I have connected
to the Access.mdb using ADO.Net.

When I click on a navigation button, it doesn't matter which navigation
button, the text boxes are not updated to show the new navigated record. I
have included the code I'm using below. I have removed all code I'm sure
does not affect the DataBinding process and I have only left the code for
the MOVE_NEXT button. WHEN THE FULL LISTING IS COMPILED THERE ARE NO
ERRORS.

Any help as to why its not updating correctly will be much appreciated.

Kind regards,
Jon.
-------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace ClientInfo.cs
{

public CurrencyManager currManager;
public DataSet myDSet;
public OleDbDataAdapter myDAdapter;

public frmClientInfo()
{
InitializeComponent();
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=A:\
ClientInfo.mdb";

OleDbConnection myConn = new OleDbConnection(strConn);
myDSet = new DataSet();
myConn.Open();
myDAdapter = new OleDbDataAdapter("SELECT * FROM ClientInfo", myConn);
myDAdapter.Fill(myDSet,"ClientInfo");
Bind();
currManager = (CurrencyManager)this.BindingContext[myDSet.Tables
["ClientInfo"]];

static void Main()
{
Application.Run(new frmClientInfo());
}

public void btnViewNext_Click(object sender, System.EventArgs e)
{
this.currManager.Position += 1;
}
public void Bind()
{
txtName.DataBindings.Add("Text", myDSet, "ClientInfo.Name");
txtAddress1.DataBindings.Add("Text", myDSet, "ClientInfo.Address1");
txtAddress2.DataBindings.Add("Text", myDSet, "ClientInfo.Address2");
txtAddress3.DataBindings.Add("Text", myDSet, "ClientInfo.Address3");
txtAddress4.DataBindings.Add("Text", myDSet, "ClientInfo.Address4");
txtPostcode.DataBindings.Add("Text", myDSet, "ClientInfo.Postcode");

txtPrimaryContactNo.DataBindings.Add("Text", myDSet,
"ClientInfo.PrimaryNo");

txtSecondaryContactNo.DataBindings.Add("Text", myDSet,
"ClientInfo.SecondaryNo");

txtEmail.DataBindings.Add("Text", myDSet, "ClientInfo.Email");
}
}
}
-------------------------------------------------------------------------

--
Message posted via http://www.dotnetmonster.com

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails....
9
by: Karl Roes | last post by:
Hi All, I would like some advice on Next / Previous record buttons. I have a main form for the client, and a continuous subform listing client...
2
by: Anand Ganesh | last post by:
Hi All, How to Implement Move Next, Move Previous, Last Record and First Record in a DataGrid Control ? Is there any standard tool available in...
2
by: tperri | last post by:
I was wondering if there was any way to use a graphical Next and Previous button instead of displaying text for the Next & Previous functionality. ...
3
by: dekern | last post by:
Good afternoon all, I guess I am missing the benefit of using datasets with Crystal. For years I have written wrapper apps that used the Pull...
1
by: Reb | last post by:
Hi all, I have not successfully found a Javascript sample for getting next and previous links from a file... I figured that someone must have...
1
by: shapper | last post by:
Hello, Is it possible to use images as Next / Previous buttons on an Asp.Net 2.0 GridView? Thanks, Miguel
6
by: empiresolutions | last post by:
I'm trying to slightly alter the script found here, http://www.adrianhodge.com/web-design/mootools-horizontal-div-slider-121/. What i want to do...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.