5 Replies - 2205 Views - Last Post: 11 February 2013 - 10:13 PM Rate Topic: -----

#1 nurul elena  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 13

Display data into datagrid with open file dialog

Posted 05 February 2013 - 08:03 AM

need help for my FYP....im new in vb
i use open file datalog to open file but still i cannot display the data needed into datagrid..
it would be pleasure if someone can help me..
data i plan to use is either in excel or access format
Is This A Good Question/Topic? 0
  • +

Replies To: Display data into datagrid with open file dialog

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3473
  • View blog
  • Posts: 11,795
  • Joined: 12-December 12

Re: Display data into datagrid with open file dialog

Posted 05 February 2013 - 08:21 AM

What is FYP?

You'll need to show some of your code..

Added: If it is a five-year plan then I suppose there is no immediate rush.

This post has been edited by andrewsw: 05 February 2013 - 08:23 AM

Was This Post Helpful? 0
  • +
  • -

#3 nurul elena  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 13

Re: Display data into datagrid with open file dialog

Posted 05 February 2013 - 08:43 AM

FYP = Final Year Project

Private Sub Open_Click()
CommonDialog1.Filter = "All files (*.*)|*.*"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen

End Sub


i just know and understand until here..
i don't know what code to use to fill in the data from excel into datagrid
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3473
  • View blog
  • Posts: 11,795
  • Joined: 12-December 12

Re: Display data into datagrid with open file dialog

Posted 05 February 2013 - 09:24 AM

You need to wrap your code in code tags - it shows you how to do this directly in the area where you are typing your post.

Firstly, is your Excel data suitable? It should contain a sheet which contains a single table of data, starting at A1. It can contain other sheets, but the sheet that contains the data should only have a single table, and nothing else.

You can use OLEDB or ADO to bind your Excel data to the grid;
You can use Excel Interop (Automation) to read the Excel rows and bind the data.

There are probably tutorials here at DIC or there is plenty of information if you Google.

BTW You can modify your dialog settings so that it only displays Excel files.

BTWW You still need to add to your dialog code so that it stores the Excel filename and path in a string, before you can do anything else.

http://www.ehow.com/...id-control.html

This post has been edited by andrewsw: 05 February 2013 - 09:26 AM

Was This Post Helpful? 1
  • +
  • -

#5 nurul elena  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 13

Re: Display data into datagrid with open file dialog

Posted 06 February 2013 - 06:56 AM

thank you :smile2:
Was This Post Helpful? 0
  • +
  • -

#6 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Display data into datagrid with open file dialog

Posted 11 February 2013 - 10:13 PM

Quote

You can use OLEDB or ADO to bind your Excel data to the grid;
Let me expand a bit on Andrew's answer. OLE DB and ADO are different aspects of the same technology. OLE DB is a collection of classes that broker data transfer. There are "OLE DB Consumers" and "OLE DB Providers". OLE DB Consumers use OLE DB objects to get and send data to and from OLE DB Providers. The providers access their data store in whatever way they want, but they use OLE DB objects to get and send data to and from the OLE DB Consumers. So OLE DB is the broker between the business layer and the data layer.

ADO is an OLE DB consumer, and the one that nearly everyone uses. Pretty much every data store out there has an OLE DB provider written for it; there are OLE DB providers for SQL Server, for Oracle, for IBM AS400, even for CICS and other mainframe technologies. There is also the "Joint Engine Technology" or JET provider, which is used for any ISAM (Indexed Sequential Access Method) database. Examples are, of course, Access, but also dBase, Paradox, Clipper, FoxPro, and several others.

Excel also uses JET, with a few extended properties set to tell JET that it's working with an Excel data store. For example, an ADO Connection object's ConnectionString property value might look like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"
Note that the first value (values are semicolon-separated) is the "Provider", which in this case is the OLE DB provider for JET. The extended properties in this case are you are using Excel, your data has a header, and force mixed data types to be converted to text. (IMEX=0 will cause the driver to assume that the column is whatever type is in the first row. If the first value is a number, then any text values in subsequent rows will be forced to null. Usually we don't want that behavior, hence IMEX=1.)

This post has been edited by BobRodes: 14 February 2013 - 04:40 PM

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1