Click here to Skip to main content
16,013,338 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can someone please tell me if its possible to copy the data from an array to a table in ms access? If so how?? could you please explain. Also if its not possible is there a way around it in which i can extract the data and put it in a table in database. Please can someone help.

thanks
Posted
Comments
Maciej Los 2-May-12 15:29pm    
Yes, it is possible, but what kind of array do you mean? What you have done till now?

Before you start programming, you need to read few articles:
Arrays in VB[^]
ADO.NET[^]
Editing an Access Database[^]
Using ADO.NET for beginners[^]
Using Transactions in ADO.NET[^]

Developers community number 1 connection string reference[^]

How to add data in ms Access[^]
Running acccess query in vb.net[^]
ADO.NET Code examples[^]

Scenario:
1) open connection to the database
2) walking through all records in array (using for...next[^] or do...while[^] loop):
--->a) create sql command to insert data into Access table (INSERT INTO[^])
--->b) execute command
3) close connection

That's all!

PS
In the future you need to be more specific, if you would like to get help (exactly what you want).
 
Share this answer
 
Comments
VJ Reddy 4-May-12 12:46pm    
Good references. 5!
Maciej Los 4-May-12 13:25pm    
Thank you, VJ ;)
Using DataTable and DataRows classes in C# .NET, you can achieve it. Here is the sample code:

C#
DataTable dt = new DataTable();
dt = dsData.Tables[0].Clone();
DataRows[] drResults = dsData.Tables[0].Select("ColName = 'criteria');

foreach(DataRow dr in drResults)
{
    object[] row = dr.ItemArray;
    dt.Rows.Add(row);
}



You can use ODBC connection to connect MS Access DataTable.
 
Share this answer
 
Comments
Maciej Los 2-May-12 15:37pm    
My vote: 1. Why?
1) Tag: VB.NET. Your code is in C#. I know, the languages are similar, but not the same.
2) I don't see the code, where you copying data from array into access table.
alom_93 2-May-12 15:41pm    
can you explain what i do here:

DataRows[] drResults = dsData.Tables[0].Select("ColName = 'criteria');

foreach(DataRow dr in drResults)
{
object[] row = dr.ItemArray;
dt.Rows.Add(row);
Maciej Los 2-May-12 17:18pm    
Yes, i can, but i won't...
You have assumed that the OP holds the data in the DataSet object (dsData), but he asks for a array!

Sorry, i was thinking, that is a comment of Genesan... You need to provide more informations. What kind of array? Where you store your data? Is it multidimensional array?
alom_93 3-May-12 7:06am    
hi,
Its is an array of records.. It just stores students names and marks in to the array. However i then want to take each name and mark and store it in ms access database.
Maciej Los 3-May-12 7:18am    
Please, see my solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900