Results 1 to 9 of 9

Thread: Bound Datagrid dumb question

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    6

    Question 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

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    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?

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    6
    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

  4. #4
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    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......

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    6
    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...

  6. #6
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Ok, but can't you then use the events fired by the filesystemwhatcher to do an update of the dataset?

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    6
    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.

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    6
    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
  •  



Click Here to Expand Forum to Full Width