Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2008, 04:49 AM
Registered User
Join Date: Jun 2008
Location: Kuala Lumpur, Selangor, Malaysia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Gini
Default Need help with coding

I want to create a code in vb.net 2008 that will delete data from its database table(Microsoft Access). The columns (attributes) in the database table are CWNo, Name, IC No, Nationality, Company, Join Date and Expiry Date.
Then it will insert data from a Microsoft Excel Sheet that contains the same attributes above into the same access database table.

Can you please give me a hint on how I can do this? Maybe you can provide me with an algorithm or even code that will be useful for me to complete the task above.
Reply With Quote
  #2 (permalink)  
Old July 1st, 2008, 01:32 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

You've asked a pretty broad question and provided nothing to inform us of what you do or do not know. If you are a beginner, then you should probably start with simple tutorials and/or a book. There are plenty out there.

Reply With Quote
  #3 (permalink)  
Old March 6th, 2009, 04:14 PM
Registered User
Join Date: Dec 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Hi, I spent a while trying to figure this out and assumed there would be an easy way to move data between Access and VB .NET. In the end I got the following to work. It is a little unwieldy, but it basically returns a query result as a collection with arrays for the field names and the record data separately:

PrivateSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
Dim queryString AsString = "SELECT * FROM [table name];"
Dim callsigns AsNew Collection
callsigns = query_database(queryString, )
PrivateFunction query_database(ByVal query_string AsString, OptionalByVal connect_string AsString _
= "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\yourdatabase.accdb") As Collection
Dim query_result AsNew Collection
Dim row_count AsInteger = 0
Dim field_count AsInteger
Dim loop1 AsInteger
Using dbConnection AsNew OleDb.OleDbConnection(connect_string)
Dim cmd AsNew OleDb.OleDbCommand(query_string, dbConnection)
Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader()
field_count = reader.FieldCount
Dim labels(field_count - 1) AsString
For loop1 = 0 To field_count - 1
labels(loop1) = reader.GetName(loop1)
Next loop1
Dim table(field_count - 1, 0) AsObject
While reader.Read()
ReDimPreserve table(field_count - 1, row_count)
For loop1 = 0 To field_count - 1
table(loop1, row_count) = reader(loop1)
Next loop1
row_count += 1
query_database = query_result

Hope you find it useful, albeit a little late! It probably works for delete type queries as well although I haven't tried it.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding Help sugunakar Classic ASP Professional 2 March 30th, 2008 04:42 PM
help with coding mastrgamr C++ Programming 15 November 10th, 2006 07:55 AM
Help coding here Scoob PHP How-To 3 January 26th, 2006 11:18 AM
coding mdlan PHP Databases 1 May 28th, 2005 07:40 PM
can someone help me in coding this? somanchivasu Access 1 April 5th, 2004 02:41 PM

All times are GMT -4. The time now is 06:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.