iterate through datagrid records row wise and insert new records into access database

chandrubngit

Member
Joined
Jul 30, 2008
Messages
9
Programming Experience
Beginner
I need to import excel records into access database using vb.net 2003.i’m successful in retrieving records from excel to datagrid.
The datagrid may have 1000 records with 10 columns.I need to iterate through each row of datagrid to find whether this record is
already exist in access database 2003.i have given 3 field combination as primary key in database.if record already exists in
Database it should ignore that row and check for next record of datagrid.and if tht record not found in database then it should able to insert that new record to access database.i need ur valuable suggestion regarding how to proceed
Or any sample codes wil help me a lot.
Please give me the solution as early as possible...

Thanking you in advance.
Regards
Chandru
 
Er.. can we answer the OP's question?

Chandru, dont bother checking the row to see if it is there, just insert it anyway and catch the Exception that will happen if the row is there (primary key violation)

If you need help writing the code to insert a row to the db.. take a look at the DW2 link in my signature, section on Saving Data
 
Er.. can we answer the OP's question?

Sorry, I didn't realise this was strictly for Q&As :rolleyes:

I thought my question would help discover areas in which I might be doing the wrong thing.

While you may have a very good understanding in these areas cjard, you don't need to make others feel they are time-wasting idiots for taking the time to post. (Or maybe you do?)

After all, a forum is for discussion isn't it?
 
Of course, and I'm the first to promote active discussion (and argue with moderators about it) so long as it's relevant to the OP's question. As a moderator myself, I have often seen the case where the OP has asked a question and the firs tposter in the thread has answered the question he wants to answer, ot answered a question he thinks should have been asked. The entire thread has wandered off on a tangent never actually answering the OPs question..

So, apologies for putting it across like I did - I didnt mean for it to be demeaning.. However, best practice for forums like this is to answer the question first, then diverge, or question the proposed solution to the problem (not question the problem) and possibly provide a better one. If I've misunderstood your post then pelase accept an apology for that too, but as I saw it, the OP had a problem, envisaged a solution, and you were trying to alter the problem, rather than provide a solution, or fix the error in the proposed the solution ;)
 
Back
Top