473,485 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4931
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
9582
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
50379
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
2128
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
5001
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
7483
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
18693
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
7357
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
8702
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
3712
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
7084
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6954
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7107
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1367
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
593
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
239
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.