?
Solved

Export DATAGRID to MS ACCESS

Posted on 2006-05-19
6
Medium Priority
?
681 Views
Last Modified: 2010-05-19
Is there any method for me to export datagrid's data to ms access using sql-query?

please advise.
0
Comment
Question by:bcolour79
  • 3
  • 2
6 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 16716367
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16716374
Hello bcolour79,

you could look at this article containing a sample how to create an access db through ADOX and a table, when you have this table created you can loop through the grid and write the records through inserts to your new table
source: http://www.codeguru.com/vb/gen/vb_database/microsoftaccess/article.php/c5149/

hope this helps a bit
bruintje
0
 
LVL 1

Author Comment

by:bcolour79
ID: 16716680
bruintje,

I'm not trying to create a new access db. I just want to export the current datagrid info into my access db.  :)

Thank you,
bcolour
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 44

Expert Comment

by:bruintje
ID: 16716692
i missed the other thread i think Sancler already gave some usefull info
0
 
LVL 1

Author Comment

by:bcolour79
ID: 16716702
for example,

i've move some of the tables from a few excel files into datagrid, then i would like to select just a few coloumn to be insert back to access :

excel to Datagrid shows :
===============
Name    Age    Address
===============
Jane       20      555, Garden Palace
Eason     21      888, Garden Palace

I just want "name" and "age" to be inserted into on of the table in my access db.

Thank you

bcolour.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16717044
there is some example code here
source: http://www.experts-exchange.com/Q_21064988.html
--------
Dim OleDbConn1 As OleDbConnection

'Here my access database file is in c:\,  replace it with ur file location
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb.mdb;User Id=admin;Password=;"

'The Sql string is very important and take great care to design it. If the data type in the table is Varchar, use single
'Quotes at the two ends of the TextBox.Text... and if the datatype is integer do not use any single quote and use
'val(TextBox.Text) to get the value of the text inside.
Dim SqlStr As String = "INSERT INTO ms_customer VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "'," & Val(TextBox3.Text) & ")"

Dim Cmd As New OleDbCommand(SqlStr,OleDbCon1)
OleDbCon1.Open()
Cmd.ExecuteNonQuery()   'This command will insert the data.
OleDbCon1.Close()
--------

be sure to read the whole thread it contains some good advice on quotes in texts and inserting into the db
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question