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