Datatable and datarow.

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 22
Reputation: isaackhazi is an unknown quantity at this point 
Solved Threads: 0
isaackhazi isaackhazi is offline Offline
Newbie Poster

Datatable and datarow.

 
0
  #1
Nov 26th, 2008
Doing a small project in which data from warranty cards are entered into a database ie. warranty card number, salesman name and ID, etc etc......after all the data has been entered into the database I need to check and see if there are any duplicate warranty card numbers in the database.

The way I am thinking is that ill first load the table into a dataset and datatable and then loop through all the records using the datarow object. compare each each record with all the other records and if i find a duplicate ill probably set a flag to make both invalid. I understand the concept but i am not too comfortable using all these objects ie datatable, datarow. It would be great if you could give me a simple syntax on how to loop through all the records using a datarow object.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: Gayan Wijeratne is an unknown quantity at this point 
Solved Threads: 0
Gayan Wijeratne Gayan Wijeratne is offline Offline
Newbie Poster

Re: Datatable and datarow.

 
0
  #2
Nov 28th, 2008
Dear Friend

I can not accept Your procedure .

I think you should check it before entering the syatem.

Check it before entering the system.

Suppose your dataset is ds;

dim count as integer

count=o
while (count < ds.rows.coun)

if ("Code is here"=ds.rows(count).ItemArray("Colomn No from table")
msgbox "Duplicate data"
else
end if
end while


Try it ...................
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Datatable and datarow.

 
0
  #3
Nov 28th, 2008
hmmm..... Shouldn't thé approach be : only insert a warranty-card-number into the database after a check if the card-number already exists?
You could write a stored procedure for example in which you use a 'transaction' which will be roled back if the cardnumber exists?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 16
Reputation: Rogachev is an unknown quantity at this point 
Solved Threads: 2
Rogachev Rogachev is offline Offline
Newbie Poster

Re: Datatable and datarow.

 
0
  #4
Nov 28th, 2008
dim _rows() as DataRow = mDataSet.Tables(TableName).Select("CardNumber = " & cardNumber)
if _rows.Lenght > 0 Then
.....
else
....
end if


I Agree. It is very strange to check duplicate after entered to database. You need to do it before.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 22
Reputation: isaackhazi is an unknown quantity at this point 
Solved Threads: 0
isaackhazi isaackhazi is offline Offline
Newbie Poster

Re: Datatable and datarow.

 
0
  #5
Nov 30th, 2008
thanx guys............well the problem is, its not a new project.........some other programmer has already created the database and entered a lot of data ......so, im trying to use the same database.......
Well from the information ive got , the company wishes to have duplicate data. I guess because they are not sure which data is legitimate......Well, at the end of it i need to check for duplicates after the data is entered.......No choice guys......

So getting back to the problem as i mentioned before .... I think i would use the code you gave me above as follows:
  1. for(count = 0;count < ds.rows.count;count++)
  2. for(count1 = 0;count<ds.rows.count;count1++)
  3.  
  4. if (ds.rows.(count1).ItemArray("coulmn No from table")=ds.rows(count).ItemArray("Colomn No from table")
  5. "What ever action to be taken"
  6. else
  7. end if

Do you think this would work??........Any other ideas?? All this because if there are duplicates I have set the record as duplicate but i need it to be present in the database.
Thnx again guys. Appreciate it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC