473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ 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()
{
InitializeCompo nent();
}

#region Variabili
string connString = "Provider=Micro soft.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(obje ct sender, EventArgs e)
{
OleDbDataAdapte r Dada = new OleDbDataAdapte r(querySelect,
connString);
OleDbCommandBui lder Cbil = new OleDbCommandBui lder(Dada);
Dada.Fill(dt);

//BindingSource bsource = new BindingSource() ;
bsource.DataSou rce = dt;
dataGridView1.D ataSource = bsource;
}

private void button1_Click(o bject sender, EventArgs e)
{
string queryInsert = "insert INTO TabNomi
VALUES('luca',' pino')";
OleDbDataAdapte r da = new OleDbDataAdapte r(queryInsert,
connString);
OleDbCommandBui lder Cbil = new OleDbCommandBui lder(da);
da.Fill(dt);

//BindingSource s = new BindingSource() ;
bsource.DataSou rce = dt;
dataGridView1.D ataSource = bsource;
}
}
Jun 27 '08 #1
4 4955
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...@g mail.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(o bject sender, EventArgs e)
{
string queryInsert = "insert INTO TabNomi
VALUES('marco', 'pino')";
OleDbDataAdapte r da = new OleDbDataAdapte r(queryInsert,
connString);
OleDbCommandBui lder Cbil = new OleDbCommandBui lder(da);
da.Fill(dt);

bsource.ResetBi ndings(false);

bsource.DataSou rce = dt;
dataGridView1.D ataSource = 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...@g mail.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
9717
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 the datagridview and have to changes written to the Filters table in an MS Access database. The if the user chooses, clicking on the Restore button empties the contents of the Filters table, refills it with the contents of the DefaulFilters...
6
50477
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 DataTable. No problem here. However, when I add data (programatically) to the DataTable, the DataGridView does not refresh right away. If I minimize and show my form,
5
2155
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 cells - they are generated through the odswierz_frekfencje() function (listed below)-
2
5019
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 column A binds to string A and column B binds to int B. When i start two threads, the datagridview able to show two rows and updated int B at run time. How? public class Foo { public Foo()
3
7596
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 Sub to the worker so that the latter can refresh the DataGrid after updating the DataTable driving it. When I run the app under the debugger, everything's fine. But when I run it for real, it hangs, apparently in the Refresh() method of the...
4
18710
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 put DataGridView and BindingSource, and connected them (BindingSource of course is also connected with DataSet). Next on the separated thread I'm reading data from DB and load them do DataSet (more preciselly, readed data I've saved as XML and...
7
7388
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 how to refresh? Thanks in advance Venky
1
8773
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
3759
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 presses a button to do a SQL query (fill a DataSet). Before firing the query, I disable the grid/buttons and turn on UseWaitCursor. After it completes, I re-enable the grid/ buttons, refresh the dataset, then turn off the UseWaitCursor. If I...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6668
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
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 we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.