HELLO world, this is my first post and heres my problem.
I have an excel spreadsheet with 22 columns, and undefined amount of rows. I need vb.net to read the data from excel. Then use that data to populate an existing access database table that has been added to visual studio. I've tried multiple approaches and have come to a standstill.
this was approach 1 -
Imports System.Data.OleDb
-
Imports System.Data.SqlClient
-
Imports Excel = Microsoft.Office.Interop.Excel
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportFile.Click
-
'Open File Dialog to Find the file.
-
FD.InitialDirectory = "C:\"
-
FD.Title = "Choose an Excel File to load"
-
FD.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"
-
FD.ShowDialog()
-
'Open File
-
FD.OpenFile()
-
-
'Read Excel Filei
-
Dim xlApp As Excel.Application
-
Dim xlWB As Excel.Workbook
-
Dim xlSheet As Excel.Worksheet
-
-
-
Dim range As Excel.Range
-
Dim intRowCount As Integer
-
Dim intColumnCount As Integer
-
-
Dim taMeasurement As New FOSRLab3DataSetTableAdapters.Sample_MeasurementsTableAdapter
-
xlApp = New Excel.ApplicationClass
-
xlWB = xlApp.Workbooks.Open(FD.FileName)
-
xlSheet = xlWB.Worksheets(1)
-
range = xlSheet.UsedRange
-
Dim ta As New FOSRLab3DataSetTableAdapters.Sample_MeasurementsTableAdapter
-
-
-
-
For intRowCount = 2 To range.Rows.Count
-
SiteID = CType(range.Cells(intRowCount, 1), Excel.Range)
-
drSiteID.SiteName = SiteID.ToString
-
Next
-
xlWB.Close()
-
xlApp.Quit()
-
releaseObject(xlApp)
-
releaseObject(xlWB)
-
releaseObject(xlSheet)
-
-
-
End Sub
-
Heres another failed approach -
'For Each row As Microsoft.Office.Interop.Excel.Worksheet
-
'xlSheet.Cells(1, 1) = "SiteName"
-
'Next
-
'MsgBox(xlSheet.Cells(1, 1).ToString)
-
-
-
-
'Try
-
'Dim MyConnection As System.Data.OleDb.OleDbConnection
-
'Dim DtSet As System.Data.DataSet
-
' Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
-
' MyConnection = New System.Data.OleDb.OleDbConnection("provider = Microsoft.Jet.OLEDB.4.0;"" Data Source = FD.FileName';""Extended Properties = Excel 8.0;")
-
' MyCommand = New System.Data.OleDb.OleDbDataAdapter("SELECT * from [Site Data]", MyConnection)
-
' MyCommand.TableMappings.Add("Table", "TestTable")
-
' DtSet = New System.Data.DataSet
-
'MyCommand.Fill(DtSet)
-
'DataGridView1.DataSource = DtSet.Tables(0)
-
'MyConnection.Close()
-
'Catch ex As Exception
-
'MsgBox(ex.ToString)
-
'End Try
-
1 1481
Would this help maybe? If not, have you tried Google?
joedeene
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: MARK TURNER |
last post by:
Hi,
Can anyone point me in the right direction to learn how to
get real time updates in an Access form from an Excel spreadsheet?
I'm trying to link the following formula which exists in an Excel
spreadsheet and works perfectly to an Access form. It's just like
a checkbook register.
C2=(C1-A2+B2)
|
by: news.giganews.com |
last post by:
Does anyone know if there's an easy way to export or copy the relationship
structure from one mdb to a new one? The relationships in the db are time
consuming to reproduce. I am trying to make a copy of a database including
all the relationships, forms, queries and modules while still within the
original database. This has to be a relatively automated process (button
click). Any suggestions?
|
by: kelvinweb |
last post by:
Hi All,
How to using asp script update data in Excel Spreadsheet with style
(ie, Bold, Font Size ..) ?
Is it possible to do that ?
|
by: miffe |
last post by:
Greetings,
I've got an access database on a server, and in a client PC I've got an excel spreadsheet... I run a query from the client PC involving some maths to develop different price lists from values stored in the DB on the server...
Problem #1: I dont want the client PC to be able to control the queries, is there a way to store the access query on the server PC and have the excel worksheet just access it on the server each time?
...
|
by: farhaaad |
last post by:
Hi everybody,
I just wanted to know if i can make a form in excel (the same as
access forms), so when i enter data in excel form it goes to a table
in access ? I mean when i enter a value in a cell linked to access
table, it goes to table and when i enter another value in the same
cell the value goes to the next record.
I thank you people in advance!
| |
by: DyingIsis |
last post by:
Hello -
I'm a relatively new user of Access.
None the less, I have a function within Excel that I would like to recreate in Access.
The function called (Check if part of a cell matches specific text) in Excel is below:
=IF(ISNUMBER(SEARCH("v",A2)),"OK", "Not OK")
I have been trying to replicate it in Access with little luck.
|
by: pochimen |
last post by:
Hi everyone, i`m trying to make access interact with excel in vba
I have an excel sheet with 3 columns and 30 rows, and an access table of 4000 rows.
The idea is to compare every row of the excel from only one column with every row of my access table from only one column of the same type.
For examle:
My excel has 3 columns: Code, Name, City.
My access table has 4 columns: Code, Name, City, Country.
|
by: risk32 |
last post by:
OK. So I have NO idea what I'm doing. I've only worked with Excel VBA, JS, and HTML. No clue how to use access since it's different (except maybe the VB portion of Excel VBA).
I'm trying to make a login form with the standard txtUser txtPassword
lblUser lbl Password, a reset button a cancel button and a login button.
This part, pretty easy, Now, need the Visual Basic portion of it to reflect the Access portion of it. I honestly have no...
|
by: TrevoriousD |
last post by:
hi
I have created a data link from access query to excel. I use excel pull data from access in order to do stats. the excel workbook always stays in the same folder as the access db. I want to be able to copy the folder from one pc to another and keep the data connection from access to excel within the same folder. I looked for way to do this in the ODC file but aren't having any luck.
In the Connecting string(in excel data connection) it...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |