473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 4920
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.