Avatar of andyd70
andyd70Flag for Australia

asked on 

Refresh data in a Bound datagridview VB.NET

I have a datagridview in a Windows Forms Vb.NET App. The datagridview is filled in the following manner.
Dim daLines As New SqlDataAdapter("Select L.CIV_LINE_ID, L.CIV_HD_ID, L.LINE_NO, L.PRODUCT_CODE from IMPORTED_CIV_LINES L  WHERE L.CIV_HD_ID = '" & grdInvoiceList.CurrentRow.Cells(7).Value.ToString & "'", dbacotconn)

        daLines.Fill(dslines, "LINES")
        grdLines.DataSource = dslines
        grdLines.DataMember = "LINES"

As I do some cell formatting the dslines is declared as a public var.
The datagridview is filled when the user selects a row in another grid.
What I have found is that the datagridview is not clearing. The results are appending to the results of the last time it was filled. I thought I would then perhaps try to delete the contents of the datagridview and re-fresh/re-read when the DA Filled the DS. I cannot get this to work.
Can anybody provide me an easier way of refreshing data in a datagridview from a Dataset ???
Visual Basic.NET

Avatar of undefined
Last Comment
andyd70
Avatar of appari
appari
Flag of India image

add the following lines before daLines.Fill(dslines, "LINES")


if not dslines is nothing then
dslines.dispose
dslines = nothing
endif
dslines = new dataset
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of andyd70
andyd70
Flag of Australia image

ASKER

I know that i have tried this before, The Problem was that it failed initially. I put the Table.Clear inside a Try Catch block and all worked.

Thank you for your help
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo