|
-
Dec 16th, 2002, 01:42 PM
#1
Thread Starter
New Member
Bound Datagrid dumb question
Ok, now am I assuming too much with a bound grid. I would expect that when I populate a dataset with an OleDbDataAdapter, then bind it to a datagrid that whenever the database is updated, the application datagrid would reflect the change automatically. Initally, I get the information just fine, however if I add a table while my application is open, the grid does not update. Is there an attribute I need to set? Thanks for your help. Here is my code:
Sub loadMsgGrid()
Dim Message_TABLE_NAME As String = "MessageTable"
'Database conection
Dim cn As New OleDb.OleDbConnection(gc_connect)
CN.Open()
'DataAdapter
Dim DA As New OleDb.OleDbDataAdapter _
("Select id, message,status,filename from Messagetable", CN)
AddHandler DA.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf DA_RowUpdated)
'Dataset
Dim DS As New DataSet()
' Populate the DataSet with the information from the MessageTable table.
DA.Fill(DS, Message_TABLE_NAME)
DS.Tables(Message_TABLE_NAME).Columns("ID").ColumnMapping = MappingType.Hidden
DS.Tables(Message_TABLE_NAME).Columns("message").ColumnMapping = MappingType.Hidden
' Bind the DataGrid to the Message table in the DataSet. This
' will cause the Message information to display.
MsgGrid.DataSource = DS.Tables(Message_TABLE_NAME)
CN.Close()
End Sub
-
Dec 17th, 2002, 09:47 AM
#2
Registered User
I might be able to help but I am not sure I know what you mean....
What is it that you are adding, and how? Are you adding rows to the Message_TABLE_NAME from code, and its not updated in grid?
Can you elaborate a bit please?
-
Dec 17th, 2002, 09:53 AM
#3
Thread Starter
New Member
I have a separate app that is monitoring a directory. When a file appears in the directory the app writes the contents of the file into a db record.
A separate client app monitors the db so that the client can respond to the newly posted records. I want the user to have the ability to not have to press a refresh button, and to not run a timer to update the grid every x secs.
If there is some way to trigger a system message from SQLServer which my app can listen for would be the best solution. However, I am not sure this is possible (or how to do it)
Let me know if you need more information. Thanks
-
Dec 17th, 2002, 10:10 AM
#4
Registered User
Aha OK, I see.
Well the DataSet is built for disconnected ADO in .NET. You are working against the DataSet and then you make sure its updated. And if you need to check for changes you have to update your table.
So I guess you have to do this with some kind of a trigger as you mentioned. I do not know if you can listen to the SQL server for a trigger or something like that because I never tried it.
You might be able to take advantage of a FileSystemWatcher though. The only example that I have is in a book, but if you search for "FileSystemWatcher" in the help you will get examples of how to do it and they are pretty easy. I made a FileSystemWatcher to trigger my application when a file was created or deleted in a folder with almost no effort.
I am sure that there is other ways to do this, but I don't know them...... yet anyway......
-
Dec 17th, 2002, 10:17 AM
#5
Thread Starter
New Member
Thanks for the help. I already have all the file watcher stuff working. The app is also build, just trying to find a solution to the datagrid auto-update problem. I will keep searching...
-
Dec 17th, 2002, 10:24 AM
#6
Registered User
Ok, but can't you then use the events fired by the filesystemwhatcher to do an update of the dataset?
-
Dec 17th, 2002, 11:17 AM
#7
Thread Starter
New Member
In short:
App1 - Filewatcher: sees and processes a file then writes the information to a db record. Some information in the file is incomplete and needs human processing to complete.
App2 - Monitor: A user monitors for incomplete information (the datagrid), then the user opens the record and completes the information.
-
Dec 17th, 2002, 11:27 AM
#8
If you did want App1 to send a message to App2 you could use Remoting to do so (or the old API way). In fact one App1 could notify many App2s and it could work over a network or the internet if you want, but it might be more than is needed.
-
Dec 17th, 2002, 12:16 PM
#9
Thread Starter
New Member
Thanks Edneeis, a preliminary look at remoting might just work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|