473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to erase the previously loaded data in datagrid?

everytime i load the data to datagrid the previous data is added wid the recent data?

how erase the previously loaded data in datagird?

my code is..
Expand|Select|Wrap|Line Numbers
  1. cnString = "server=localhost;User Id=root;database=aries_project"
  2.             'sqlQRY = "Select * from employees_info"
  3.  
  4.  
  5.             sqlQRY = "SELECT assigned.id,assigned.emp_id,assigned.itemno,inventory.`description`,assigned.`quantity`,inventory.amount,inventory.`amount`* assigned.`quantity` AS Amount,assigned.remarks,assigned.datetime FROM `aries_project`.`employees_info` INNER JOIN `aries_project`.`assigned` ON (`employees_info`.`emp_id` = `assigned`.`emp_id`) INNER JOIN `aries_project`.`inventory` ON (`assigned`.`itemno` = `inventory`.`itemno`) WHERE assigned.emp_id=" & Label1.Text & " "
  6.  
  7.  
  8.             conn = New MySqlConnection(cnString)
  9.  
  10.             'strSQL = "SELECT * from employees_info"
  11.             conn = New MySqlConnection(cnString)
  12.             Try
  13.                 'Open CONNECTION
  14.                 conn.Open()
  15.                 da = New MySqlDataAdapter(sqlQRY, conn)
  16.                 'create command builder
  17.                 Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
  18.                 'fill dataset
  19.                 da.Fill(ds, "assigned")
  20.                 DataGridView1.DataSource = ds
  21.                 DataGridView1.DataMember = "assigned"
  22.             Catch ex As Common.DbException
  23.                 MsgBox(ex.ToString)
  24.             Finally
  25.                 'Close(CONNECTION)
  26.                 conn.Close()
  27.             End Try
Apr 3 '13 #1
1 1251
vijay6
158 100+
Hey melhanz, use this line before updating 'DataGridView1' which will clear all previous records of it.
Expand|Select|Wrap|Line Numbers
  1. DataGridView1.DataSource = null;

Use like this,

Expand|Select|Wrap|Line Numbers
  1. da.Fill(ds, "assigned")
  2. DataGridView1.DataSource = null
  3. DataGridView1.DataSource = ds
  4. DataGridView1.DataMember = "assigned"
Apr 3 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: pv_kannan | last post by:
One of our dev team members is having a strange problem with a datagrid... We are not seeing a datagrid's data getting refreshed after a new row is entered in a popup window inspite of resetting...
1
by: Abc | last post by:
Namespace or type 'Data' for the Imports 'Microsoft.ApplicationBlocks.Data' cannot be found. is the error which i am getting while importing Microsoft.ApplicationBlocks.Data namespace. Can...
6
by: Rob | last post by:
I am trying to copy some data from one datagrid to another. The first datagrid containing data is called DocList. The blank Datagrid that I am trying to copy some data to is called DataGrid1. ...
0
by: earsypaul | last post by:
Hello, With MS SQL server we can bcp hexadecimal data into varbinary columns quite nicely. We're migrating some data to DB2 and trying to import to a "varchar for bit data" data type column....
3
by: olduncleamos | last post by:
Hi all, What is, in general, the preferred practice to transfer data between business objects and the data layer? To be more specific, I have a couple of business objects with state data that...
3
by: psbasha | last post by:
Hi , When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ). ...
3
by: STEPHENSS | last post by:
Hi, I have a crystal report that has many subreports over many pages and Iam getting the following error Unable to save data with report, the save data is incomplete generate the saved data Yes...
2
by: mldardy | last post by:
Error msg - Namespace or type 'Data' for the Imports 'Microsoft.ApplicationBlocks.Data' can't be found. How do I fix this error. I tried adding a reference but it is not listed in the references.
9
by: andersond | last post by:
I have a web application that allows retail insurance agents to get quotes 24/7. There is a data file for quotes, a data file for vehicles, a data file for drivers and a data file for...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.