|
Hi All,
I am facing a very annoying problem. In my Form, I have a dataGridView control which is being loaded with data at the time when Form loads. After that, with user's interation, some place, new rows are added to the Table of that DataGridView but unfortunately the The DataGridView is not showing the new rows. If I close the application and run the application again, then next time the datagridview shows the new rows. I tried with this following statement just after adding the new row.
myTableAdapter.Fill(myDataSet.myTable);
Still no respose is seen in the datagridview ( as well as the the dataSet)
Please help !!!...
Regards
Emran
|
|
|
|
|
to be noted
r u call the function which fills the grid in the page load in a '!IsPostBack' condition
also r u callin the same function again after updation of rows
sathy
|
|
|
|
|
Hi Sathy,
Thanks for replying me. I got hope that someone will help.
Ok, I am working on Windows Form. I have a Combo Box which is bounded with a dataSource named "MyDataBindingSource" and I have a DataGrid named "MyDataGrid" which is also bounded with the same dataSource "MyDataBindingSource" . Now, In order to Insert new Row or Delete existing row I use an external button which manually open database connection, Insert or Delete Rows and then close the Connection. After performing this task, I am having hard time to Update my that Combo Box and that DataGrid with the new data. I am trying so many approoach like, myTableAdapter.fill(myDataSet.MyTable) but nothing is being updated. Looks like all data which is available in the main datasource is staying in Cache and When I restart the application, then i see the new data available both in combo box and dataGrid. So, that means, My user will have to restart the application everytime they insert or delete rows and if they want to see the effect.
Please help me, I think i am missing some snippet of code which can solve this issue but as I am new, I dont know.
I appreciate your time, Thanks and regards
Emran.
|
|
|
|
|
MyDataGrid.Refresh() sounds like it might solve your issue. Without knowing more about what kind of form(web, windows, etc) or how you're modifying the underlying datatable(or where the datatable even is) I can't really give you more specific advice.
|
|
|
|
|
Hi Drew McGhie,
Thanks for responding to my request.
I have tried with myDataGrid.Refresh(), but still i dont see any updates. In order to specify my problem more accurately, I am quoting the reply here That I replid to Sathy.
Ok, I am working on Windows Form. I have a Combo Box which is bounded with a dataSource named "MyDataBindingSource" and I have a DataGrid named "MyDataGrid" which is also bounded with the same dataSource "MyDataBindingSource" . Now, In order to Insert new Row or Delete existing row I use an external button which manually open database connection, Insert or Delete Rows and then close the Connection. After performing this task, I am having hard time to Update my that Combo Box and that DataGrid with the new data. I am trying so many approoach like, myTableAdapter.fill(myDataSet.MyTable) but nothing is being updated. Looks like all data which is available in the main datasource is staying in Cache and When I restart the application, then i see the new data available both in combo box and dataGrid. So, that means, My user will have to restart the application everytime they insert or delete rows and if they want to see the effect.
Please help me, I think i am missing some snippet of code which can solve this issue but as I am new, I dont know.
I appreciate your time, Thanks and regards
Emran.
|
|
|
|
|
The question then is what you're binding to. If you open the connection, query the database and put the results in a local dataset, and use that as your binding source, you won't see any updates unless you refresh your local dataset from the remote dataset from the connection. You need to either A) refresh your local dataset when you add stuff remotely, or B) do all adding/deletion locally and then refresh the remote dataset at an approprate time(like when a user hits a save button, or on form close).
Hope this helps
|
|
|
|
|
Hi Drew McGhie,
Thanks for the tips. Yes I understood that I will have to refresh the DataSet. But I dont know the right Snippet to refresh the Disconnected DataSet So that The DataSet should Open The Connection Again and load the the new data from the Physical Database Just After Clicking a button responsible for ADD or Delete.
I thought, tableAddapterName.fill(DataSetName.TableName) Code should have worked , but It Did not refresh the DataSet (Or the Binding Source) by loading data from Physical Database.
Thanks and Regards
Emran.
|
|
|
|
|
emran834 wrote: But I dont know the right Snippet to refresh the Disconnected DataSet So that The DataSet should Open The Connection Again and load the the new data from the Physical Database Just After Clicking a button responsible for ADD or Delete.
Perfectly workin for me
this is how i did, i wrote a function for filling the grid separately and calling it on a button click event.
and i deleted a row on another button click event and called the same function again.
<br />
public void fillgriddd()<br />
{<br />
SqlDataAdapter sd = new SqlDataAdapter("select * from country",Con);<br />
DataSet ds = new DataSet();<br />
sd.Fill(ds);<br />
dg.DataSource= ds.Tables[0].DefaultView;;<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
fillgriddd();<br />
}<br />
<br />
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
SqlDataAdapter sd = new SqlDataAdapter("delete from country where ctryname = 'austria'",Con);<br />
Con.Open();<br />
sd.SelectCommand.ExecuteNonQuery();<br />
Con.Close();<br />
fillgriddd();<br />
}<br />
<br />
Hope it would help
Sathy
|
|
|
|
|
Hi Sathy,
How are you ! Thanks a loooooooooooot for the nice Help.
Ok, The way you have shown me was excellent. I could add new rows and I could see the new added row in datagrid view, but i had a problem that, the binding source was not being updated with that way, so Other DataBounded Controls lost track of that DataGridView. So, When I modified the line
myDataGridView.DataSource = resumeDataSet.Tables["job_Boards"].DefaultView;
to the following line,
jobBoardsBindingSource.DataSource = resumeDataSet.Tables["job_Boards"].DefaultView;
Then, All controld who are bounded with same databinding source started working properly.
After that, I found that, this is only working when I ADD or UPDATE rows, but when I delete, DataBindingSource is not being effected and thus DataGridView is not removing that row. After fighting with this problem for hours, I found some alternative working way.
I used the following snippet to remove the selected Row after deleting the row with a Manual SQL Query.
if (dataGridViewJobBoards.SelectedRows.Count > 0 && this.dataGridViewJobBoards.SelectedRows[0].Index != this.dataGridViewJobBoards.Rows.Count - 1)
dataGridViewJobBoards.Rows.RemoveAt(dataGridViewJobBoards.SelectedRows[0].Index);
And in this way, All problem has been solved. As DataGridView is bounded to a commonDataBindingSource which is being shared by other controls, so, removing that row had an effect of all connected controls to update their rows.
Thanks a looooooooooot. The bottom line is , My problem has been solved. I am happy.
I appreciate your co-operation.
Emran
public void refreshJobBoardBindingSource()
{
SqlDataAdapter myJobBoardAdapter = new SqlDataAdapter("SELECT job_Boards.* FROM job_Boards", sqlConnectionMain);
myJobBoardAdapter.Fill(resumeDataSet.Tables["job_Boards"]);
jobBoardsBindingSource.DataSource = resumeDataSet.Tables["job_Boards"].DefaultView;
}
|
|
|
|
|
Each user is using the .net application to connect and work with the data in the sql server database.
All the database handling code (i.e calling the stored procedures) is in a project which is inside a .sln. One of the projects in the .sln is for the UI i.e. forms.
So, we have, one .sln which contains two projects (one for UI and the other for calling the stored procedures.)
I think at present it means that we need a license for each person to connect to sql server.
If we have a webservice and place the project (Which does the database sql handling) in a datalayer (So that the webservice and the datalayer go onto one machine - middle tier) then does this mean that we only require one license for all the users to connect to sql server?
Thanks
-- modified at 19:19 Sunday 29th January, 2006
|
|
|
|
|
I am currently writing a database (Windows based) that uses this same technique... I have written a Windows service (middle tier) to "talk" to the database from the gui and all seems to be well (I am only using the free MSDE)
I have had roughly 4 concurrent connections thus far without an issue, will let you know if i run into problems
|
|
|
|
|
fmardani wrote: does this mean that we only require one license for all the users to connect to sql server?
I think so.
___________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA]
|
|
|
|
|
hello everybody in this forum.
I would like first to thank everybody here contributed in solving C3 developers' programmers.
Second.
I need to access the voice directly fom microfone and encode it . This captured voice i will transmit to over the network any help on that.
I saw full -duplex audio player in C# by ianier but really his code is complicated somewhat . I need more simple steps using the Wavein/WaveOut Api(s) or even using directSound.
Thanks Folks
Mess With The Best And Die Like The Rest
|
|
|
|
|
First off, i am not sure this is the right forum, but i plan to program in this in c#, so here goes!
I am wanting to create a small PPC app to control windows media player, mainly volume, pause/play, previous, next and mute buttons. There are apps out there which run windows media player 'servers' with wmp controls embedded into the server, but that's not what i need.
Basically i am uber lazy, i want to be able to stop the music b4 i go to bed, or stop a movie if i have been watching it from my bed. Ultimately i would also like to be able to put my laptop in suspend mode also, but thats not as difficult
Anyhow, i have searched around a bit to no avail and was wondering if anyone else has had and similar ideas, and if they had any luck controlling wmp. (i assume it would be a plugin... but again, dont know if its even possible!)
REgards,
- Martyn
|
|
|
|
|
Hello,
I am currently considering migrating various projects from 1.1 to 2.0 but before doing this I would like to see a list of all changes, enhancements, bug fixes, new bugs etc etc that are in 2.0. Looking through MSDN and other Microsoft sites I can seem to find anything that covers it all.
Does anybody know if such a list exists?
|
|
|
|
|
http://www.gotdotnet.com/team/changeinfo/default.aspx
Especially this zip file: http://www.gotdotnet.com/team/changeinfo/Beta1ObsData.zip
It covers the beta1 of the .NET 2.0 framework, but the list is (almost) complete.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
I am relatively new to C#. I have to make some kind of "search database" aplication. I have to make aplication with search field that can search specific text in some document. Can someone please help me?
|
|
|
|
|
I want to get working on Windows Presentation Foundation, but I can't find an SDK download for the full release version of VS2005 ? Is there such a beast ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I thought they (Microsoft) renamed WPF back to DirectX10 and WinFX respectively, or am I confusing something here?
Maybe it was WGF = DirectX10 and WPF = WinFX or something like that...
-- modified at 16:23 Sunday 29th January, 2006
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Thanks - I'd actually downloaded a prior versoin of this ( i.e. a different build number ). It looks to me like they don't havE IDE support for the full version yet, then. I'll have to do it all by hand, if at all.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Thanks - Cider was the keyword I needed to find all the downloads I need. Thanks a ton.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I'm hoping someone can help me with a problem I'm having with an app that reads in an Excel spreadsheet. For each worksheet in the spreadsheet I want to create a DataTable that has the same name as the Excel worksheet. My code currently looks like this:
foreach (Microsoft.Office.Interop.Excel.Worksheet ws in wrkBook.Worksheets)<br />
{<br />
<br />
if (ws.Name != null)<br />
{<br />
this.lstSheets.Items.Add(ws.Name);<br />
strWorksheet = ws.Name.ToString();<br />
System.Data.DataTable ws.Name = new System.Data.DataTable();<br />
}<br />
}<br />
This doesn't work as it thinks I'm trying to reassign an existing object, rather than create a new object with the name of an existing object's property.
Can anyone explain how I can create as many datatables as exists in the spreadsheet file I open, and programmatically give each DataTable the same name as the worksheet from the spreadsheet?
Any assistance would be gratefully recieved!
|
|
|
|