Results 1 to 5 of 5

Thread: Datagrid won't Refresh on Windows Form (RESOLVED)

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Location
    St Louis
    Posts
    6

    Unhappy Datagrid won't Refresh on Windows Form (RESOLVED)

    I am having problems refreshing my datagrid on a windows form. I have a master/detail form relationship on the form and I am deleting the data from a SQL Servre database. The data gets deleted with no problem but I cannot get the grid to refresh and show the data gone without closing the form and reopening it.

    Here is the code I use to load the data initially:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    DsHeaderDetail1.Clear()
    SqlDataAdapter1.Fill(DsHeaderDetail1)
    SqlDataAdapter2.Fill(DsHeaderDetail1)
    End Sub

    Here is the code I use to delete the data from the SQL database:

    Public Sub DeletePromoOrder(ByVal ID As Integer)
    On Error GoTo ue_error

    Dim CMD As String
    Dim myConn As SqlConnection = New SqlConnection("Data Source=STL6;Integrated Security=SSPI;Initial Catalog=RWNPROD")

    ' ------------ DELETE DETAIL RECORDS -----------------
    CMD = "DELETE FROM PODetail WHERE PODID = " & ID & ""
    'Dim DeleteDtlSQL As String =
    Dim DeleteDtlCMD As New SqlCommand(CMD, myConn)
    'SqlDataAdapter1.SelectCommand = DeleteDtlCMD
    myConn.Open()
    DeleteDtlCMD.ExecuteNonQuery()

    ' ------------ DELETE HEADER RECORDS -----------------

    Dim DeleteHdrSQL As String = "DELETE FROM POHeader WHERE POHID = " & ID & ""
    Dim DeleteHdrCMD As SqlCommand = New SqlCommand(DeleteHdrSQL, myConn)
    SqlDataAdapter1.SelectCommand = DeleteHdrCMD
    DeleteHdrCMD.ExecuteNonQuery()
    myConn.Close()

    ' I need help here to know how to refresh the datagrid(s). They are named DataGrid1(Master) and Datagrid2(Detail)

    Exit Sub

    ue_error:
    Call UE("Item Add: ")
    Resume Next
    End Sub

    Please help!!!!!!!!!!!!!
    Last edited by ronniedfw; Jul 28th, 2003 at 03:32 PM.

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