Hi, I am using visual studio 2008. I have a winforms app that takes data from an xml doc. I store the data in a ms sql database that I have created via a stored procedure. When Irun the app the data from the xml doc is captured and put in the database, but I can only see old data, the data that is captured during the current session can not be seen unless I close the app down and restart it. I have tried the following, and every variation I can think of to allow me to see the new data but to no avail. Please can anyone help. Thanks for all and any help.

'this code opens the connection and inserts new data into the dbase
 _con = New SqlConnection()
    _connectionString = My.Resources.LogOnStrings.DataSourceSQLEXPRESSAttachDbFilenameCBGame
    _con.ConnectionString = _connectionString
    _con.Open()
    Dim cmd As SqlCommand
    cmd = New SqlCommand()

    With cmd
        .Connection = _con
        .CommandType = CommandType.StoredProcedure
        .CommandText = ("InsertUser")
        .Parameters.Add("@gnumber", SqlDbType.VarChar).Value = gamenumber
        .ExecuteNonQuery()
    End With
    _con.Close()

'and then this is the code I have used in an attempt to see the newly acquired data
Try
    Me.Validate()
    Me.DBGameTableBindingSource.EndEdit()
    Me.DBGameTableTableAdapter.Update(Me.DBGameDataSet.DBGameTable)
    DBGameDataSet.GetChanges()
    Me.DBGameTableTableAdapter.Fill(DBGameDataSet.DBGameTable)
    MsgBox("Update successful")
    Me.DBGameDataSet.AcceptChanges()

Catch ex As Exception
    MsgBox("Update failed")
End Try

What are you using to display the data?

In a GridView for example, it's simply a case of

GridView1.DataBind()

Just refreshes the GridView and binds all current data to it, if you data bind just after an insert it will refresh and display the information you just inserted.

- Jordan

Jordan, thanks for the reply but the code you suggest just produces an error message, 'Bind is not a member of System.Windows.Forms.DataGridView'. I have tried to use both grid view and details view, but cannot get my new data to be displayed.
No idea what I am doing wrong or not doing or combination of both.

Well the code would need to be changed to have the correct name for your GridView of course

For example, if it's DataGridView then it would be

DataGridView.DataBind()

- Jordan

Aye, I used the name of my gridview when I generated the error. I really am at a loss.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.