473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to import any excel file in datagrid using vb6

I want to open excel file using open dialogue box and display records in datagrid
Jan 24 '07 #1
3 12877
I want to open excel file using open dialogue box and display records in datagrid

You can use the ADODB to connect in Excel files just like MS ACCESS
but you need to specify the the filename of the Excel file then try this SQL Statement

SELECT * FROM [Sheet1$]

Sheet1 is the name of the Sheet in Excel file

I hope this one will help you.

Expand|Select|Wrap|Line Numbers
  1. 'Load the Database Driver for Excel Files
  2.     With mconExcelConnection
  3.            .Provider = "Microsoft.Jet.OLEDB.4.0"
  4.            .ConnectionString = "Data Source= " & gstrExcelPath & ";Extended Properties=Excel 8.0;"
  5.            .CursorLocation = adUseClient
  6.            .Open
  7.     End With
  8.  
  9. mrsetExcelRecordset.Open "SELECT * FROM [TestSheet$]", mconExcelConnection, adOpenKeyset, adLockPessimistic
Norman
Jan 28 '07 #2
In what part of the code do you make reference to the DataGrid Object?

Thanks!

Abel
Jun 21 '10 #3
mrsetExcelRecordset.Open "SELECT * FROM " & SelWsheet, mconExcelConnection, adOpenKeyset, adLockPessimistic

What do you see wrong with the piece of code above? It Gives me Run-time error 424 Object Required. "SelWsheet" is a string variable that I get when the user selects from a List Box. It is string and it shows as "InvItem". Does it require an integer? Thanks for your insight!
Jun 23 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: deko | last post by:
I've been trying to use the Access Import Wizard to expedite importing data into my mdb. The nice thing about the wizard is that I can import from different file formats - txt, xls, even Outlook -...
2
by: Steve Chatham | last post by:
I use the following code: Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged Dim sFile As String =...
2
by: TM | last post by:
I have an Excel sheet where I setup my needed formatting, page settings, ect, and would like to take my data from a datagrid and paste it into the excel file and print the excel file. Any idea...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
1
by: Anonieko | last post by:
Here are some of the approaches. 1. Transform DataGrid http://www.dotnetjohn.com/articles.aspx?articleid=36 3. Use the Export approach ...
4
by: bluewind44 | last post by:
Hello, I made a page that used for import data from .xls files. At this page, users upload the .xls file to the server, then the app uses an OleDB connection and the Jet provider to read the data...
0
by: santosh1234 | last post by:
Hi, I have a problem in importing from an excel file. I am using the connection string for oledb to convert the data from the excel file into a datatable and proceed thereafter. Code I am using...
1
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
3
by: vj83 | last post by:
Hi, I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form. The code is here private void Button2_Click(object sender,...
8
by: shenkel55 | last post by:
I'm using Access and Excel 2003. Using either the import wizard or code, I have the same problem. This problem only happens with Excel files automatically generated by Corp IT. If I try to do an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.