472,969 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem with REFRESH DataGridView

Hi, i TRY to create a windows apllication that insert in a Access DB
name and surname; the Insert istruction Works but the the refresh of
DataGridView doesn't works...
the code is :
public Form1()
{
InitializeComponent();
}

#region Variabili
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\db1.mdb";
string querySelect = "select * from TabNomi";
string queryDel = "delete * from TabNomi";
DataTable dt = new DataTable();
BindingSource bsource = new BindingSource();
#endregion

private void Form1_Load(object sender, EventArgs e)
{
OleDbDataAdapter Dada = new OleDbDataAdapter(querySelect,
connString);
OleDbCommandBuilder Cbil = new OleDbCommandBuilder(Dada);
Dada.Fill(dt);

//BindingSource bsource = new BindingSource();
bsource.DataSource = dt;
dataGridView1.DataSource = bsource;
}

private void button1_Click(object sender, EventArgs e)
{
string queryInsert = "insert INTO TabNomi
VALUES('luca','pino')";
OleDbDataAdapter da = new OleDbDataAdapter(queryInsert,
connString);
OleDbCommandBuilder Cbil = new OleDbCommandBuilder(da);
da.Fill(dt);

//BindingSource s = new BindingSource();
bsource.DataSource = dt;
dataGridView1.DataSource = bsource;
}
}
Jun 27 '08 #1
4 4860
If it isn't auto-updating, you could call ResetBindings() on the
BindingSource; you could also change the binding (your current lines are
trivial updates - i.e. they don't change anything, so it won't refresh).

Marc
Jun 27 '08 #2
On 22 Apr, 11:14, Marc Gravell <marc.grav...@gmail.comwrote:
If it isn't auto-updating, you could call ResetBindings() on the
BindingSource; you could also change the binding (your current lines are
trivial updates - i.e. they don't change anything, so it won't refresh).

Marc
i put the istruction ResetBindings() but the datagridview don't
refresh...

private void button2_Click(object sender, EventArgs e)
{
string queryInsert = "insert INTO TabNomi
VALUES('marco','pino')";
OleDbDataAdapter da = new OleDbDataAdapter(queryInsert,
connString);
OleDbCommandBuilder Cbil = new OleDbCommandBuilder(da);
da.Fill(dt);

bsource.ResetBindings(false);

bsource.DataSource = dt;
dataGridView1.DataSource = bsource;
}
Jun 27 '08 #3
In that case... are you sure that the DataTable has been updated by the
adapter? Try manually finding (loop or whatever) the record in the "dt"
DataTable; is it there?

Marc
Jun 27 '08 #4
On 22 Apr, 12:39, Marc Gravell <marc.grav...@gmail.comwrote:
In that case... are you sure that the DataTable has been updated by the
adapter? Try manually finding (loop or whatever) the record in the "dt"
DataTable; is it there?

Marc
isee that the DataTable doesn't Update.... but the insert in Access DB
works... :-(
Jun 27 '08 #5

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

Similar topics

0
by: thomasp | last post by:
This is a two part question, 1) The code below should display a form with a datagridview and a few command buttons. This form should allow the user to make change to the records displayed in...
6
by: George | last post by:
Hi, I have been encountering a refresh problem with DataGridView, which is bound to a DataTable. When I make updates (Add, Delete, update) to the DataGridView, everything flow nicely to...
5
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of...
2
by: Ivan | last post by:
I have a class Foo which have two property. I have a thread that do some process and update class Foo int B. I have a datagridview on main form. this datagridview data source to this class Foo and...
3
by: David Cartwright | last post by:
Hi all, I'm having a weird time with a call to the Refresh() method of a DataGridView. I have a VB.NET 2005 Windows application with a main form and a "worker" thread. The main form delegates a...
4
by: shibeta | last post by:
Hello, I have problem with DataGridView and BindingSource. I have created DataSet and added TableData to it with manualy created columns (without DataAdapter - I'm not using MSSQL). On the Form I...
7
by: mvenkatesan | last post by:
Hi guys I am win appl. I was bind the datagridview from datatable. i was changed datas @ runtime. datatable changed but my datagridview not refresh. I written dagaridview.refresh(); not work ...
1
by: MFayaz | last post by:
Hello! I have to refresh datagridview when database update , IS there any way to solution that my datagridview auto refresh when any user update database. Thanks in Advance
1
by: Aegixx | last post by:
Ok, extremely wierd situation here: (I'll post the code below, after the explanation) I've got a Windows application (.NET 3.5) that has a single Form with a DataGridView embedded. The user...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.