Click here to Skip to main content
15,887,135 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionconfusion in static functions Pin
abcurl12-Jul-09 0:56
abcurl12-Jul-09 0:56 
AnswerRe: confusion in static functions Pin
Christian Graus12-Jul-09 4:34
protectorChristian Graus12-Jul-09 4:34 
AnswerRe: confusion in static functions Pin
nlarson1113-Jul-09 4:00
nlarson1113-Jul-09 4:00 
QuestionDrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 0:25
Sonhospa12-Jul-09 0:25 
NewsWorkaround: DrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 2:34
Sonhospa12-Jul-09 2:34 
AnswerRe: DrawItem for flagged listbox item? Pin
Henry Minute12-Jul-09 3:46
Henry Minute12-Jul-09 3:46 
GeneralRe: DrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 7:25
Sonhospa12-Jul-09 7:25 
QuestionRead selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk11-Jul-09 21:58
drexler_kk11-Jul-09 21:58 
Hello all,I need some help here on reading specified column and row of data from the Excel Sheet. I have manage to read the full sheet into my datagridview now,but what I need is to read specified column and row but not all.I'll try to explain it like below:

Its a table in my excel that the table start at location in the PO Detail spreadsheet of A4 until G4. And thats the Header of the table,the Header name of each column are Product Code, Description , Internal Product Code, Selling Price , Order Quantity, Amount and other.

But currently my code now read all the data into my datagridview which is not convenient for me to do further process with some unuseful details inside the PO Detail excel sheet. Can anyone teach me how could you retrieve only the column and row I need and put into the datagridview?

This is the code I have currently which read everything into my datagridview:



<br />
Imports System.Data<br />
Imports System.Data.OleDb<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        Dim MyConn As System.Data.OleDb.OleDbConnection<br />
        Dim DtSet As System.Data.DataSet<br />
        Dim MyCommand As System.Data.OleDb.OleDbDataAdapter<br />
<br />
        Try<br />
            MyConn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\OrderingFormat.xls'; Extended Properties=Excel 8.0;")<br />
            MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [PO Detail$] ", MyConn)<br />
            MyCommand.TableMappings.Add("Table", "TestTable")<br />
            DtSet = New System.Data.DataSet<br />
            MyCommand.Fill(DtSet)<br />
            DataGridView1.DataSource = DtSet.Tables(0)<br />
            MyConn.Close()<br />
<br />
        Catch ex As Exception<br />
<br />
        End Try<br />
    End Sub<br />


Thank you for reading and hope someone can give me some guidance on this issue.
Regards
Drex
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
dan!sh 11-Jul-09 22:34
professional dan!sh 11-Jul-09 22:34 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk11-Jul-09 22:51
drexler_kk11-Jul-09 22:51 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
dan!sh 11-Jul-09 23:47
professional dan!sh 11-Jul-09 23:47 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12311-Jul-09 23:52
helelark12311-Jul-09 23:52 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:17
drexler_kk12-Jul-09 0:17 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
Paramu197312-Jul-09 0:29
Paramu197312-Jul-09 0:29 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:38
drexler_kk12-Jul-09 0:38 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 [modified] Pin
helelark12312-Jul-09 0:49
helelark12312-Jul-09 0:49 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:54
drexler_kk12-Jul-09 0:54 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 0:56
helelark12312-Jul-09 0:56 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 1:21
drexler_kk12-Jul-09 1:21 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 1:24
helelark12312-Jul-09 1:24 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 1:42
drexler_kk12-Jul-09 1:42 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 1:45
helelark12312-Jul-09 1:45 
GeneralRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 2:00
drexler_kk12-Jul-09 2:00 
GeneralRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 2:10
helelark12312-Jul-09 2:10 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 2:15
drexler_kk12-Jul-09 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.