Click here to Skip to main content
       

C#

 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberEddy Vluggen21-Nov-12 14:40 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-321-Nov-12 14:52 
SuggestionRe: Automatically Compiler Generated Unique Constants ? PinmemberEddy Vluggen21-Nov-12 14:55 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-321-Nov-12 15:52 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-321-Nov-12 16:03 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-321-Nov-12 16:01 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberPIEBALDconsult21-Nov-12 17:27 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberEddy Vluggen21-Nov-12 22:08 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmvpRichard MacCutchan21-Nov-12 23:01 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-322-Nov-12 15:22 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmvpRichard MacCutchan23-Nov-12 0:24 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberBobJanova23-Nov-12 0:29 
GeneralRe: Automatically Compiler Generated Unique Constants ? PinmemberC-P-User-323-Nov-12 5:43 
QuestionDataGridView doesn't appear on screen [modified] PinmemberRickSharp21-Nov-12 13:44 
Hey guys,
 
Easy one here. I want to see the results of my datatable in the DataGridView. When i execute, it runs without errors but no DataGridView shows up on screen. Does DataGridView require a form to view the results or something?
 
What am I missing?
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FileHelpers;
using System.Data; //not used by default
using System.IO; //not used by default
using System.Data.OleDb; //not used by default
using System.Windows.Forms;
 
namespace CSVParser
{
    class CSVParser
    {
        public static DataTable ParseCSV(string path)
        {
            if (!File.Exists(path))
                return null;
 
            string full = Path.GetFullPath(path);
            string file = Path.GetFileName(full);
            string dir = Path.GetDirectoryName(full);
 
            //create the "database" connection string 
            string connString = "Provider=Microsoft.Jet.OLEDB.4.0;"
              + "Data Source=\"" + dir + "\\\";"
              + "Extended Properties=\"text;HDR=No;FMT=Delimited\"";
 
            //create the database query
            string query = "SELECT * FROM " + @"C:\Users\rsharp\Desktop\CustomerExport.csv";
 
            //create a DataTable to hold the query results
            DataTable dTable = new DataTable();
 
            //create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
 
            //try
           // {
                //fill the DataTable
                dAdapter.Fill(dTable);
           // }
            //catch (InvalidOperationException /*e*/)
           // { }

            //the DataGridView
            DataGridView dgView = new DataGridView();
 
            //BindingSource to sync DataTable and DataGridView
            BindingSource bSource = new BindingSource();
 
            //set the BindingSource DataSource
            bSource.DataSource = dTable;
 
            //set the DataGridView DataSource
            dgView.DataSource = bSource;
 
            //Dispoe of the adapter
            dAdapter.Dispose();
 
            return dTable;
        }
    }
}
 


modified 21-Nov-12 19:21pm.

AnswerRe: DataGridView doesn't appear on screen PinmemberEddy Vluggen21-Nov-12 14:17 
GeneralRe: DataGridView doesn't appear on screen PinmemberRickSharp21-Nov-12 14:27 
GeneralRe: DataGridView doesn't appear on screen PinmemberEddy Vluggen21-Nov-12 14:42 
QuestionTextbox help! PinmemberKurac121-Nov-12 12:18 
AnswerRe: Textbox help! PinmemberMycroft Holmes21-Nov-12 13:01 
QuestionSpecialized List Sorting question PinmemberNuclearMan8521-Nov-12 8:12 
AnswerRe: Specialized List Sorting question [modified] PinmemberRichard Deeming21-Nov-12 9:03 
AnswerRe: Specialized List Sorting question PinmemberSledgeHammer0121-Nov-12 9:06 
AnswerRe: Specialized List Sorting question PinmemberRichard Deeming21-Nov-12 9:32 
AnswerRe: Specialized List Sorting question [modified] PinmemberPIEBALDconsult21-Nov-12 9:57 
AnswerRe: Specialized List Sorting question PinmemberBobJanova21-Nov-12 23:50 
QuestionWinForms Class Design PinmemberMember 961929521-Nov-12 7:43 
AnswerRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 8:15 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 9:16 
GeneralRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 9:56 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 9:59 
GeneralRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 10:06 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 10:21 
GeneralRe: WinForms Class Design PinmemberPIEBALDconsult21-Nov-12 11:27 
AnswerRe: WinForms Class Design PinmemberPIEBALDconsult21-Nov-12 10:07 
QuestionUplaod Article To Codeproject PingroupkatlegoEmmnanuelNkosi21-Nov-12 4:44 
AnswerRe: Uplaod Article To Codeproject PinmemberPIEBALDconsult21-Nov-12 4:48 
AnswerRe: Uplaod Article To Codeproject PinmvpRichard MacCutchan21-Nov-12 5:34 
QuestionPrint Crystal Report in c# Using Access Database? Pinmemberkashifjaat21-Nov-12 3:09 
QuestionGenerate Morse Code Sound Pinmemberlong dao21-Nov-12 2:24 
AnswerRe: Generate Morse Code Sound PinprotectorPete O'Hanlon21-Nov-12 2:45 
GeneralRe: Generate Morse Code Sound Pinmemberlong dao21-Nov-12 2:54 
GeneralRe: Generate Morse Code Sound PinprotectorPete O'Hanlon21-Nov-12 3:05 
QuestionKeeps returning NullReferenceException [modified] PinmemberMacUseless21-Nov-12 0:08 
SuggestionRe: Keeps returning NullReferenceException PinmemberV.21-Nov-12 4:25 
GeneralRe: Keeps returning NullReferenceException PinmemberMacUseless21-Nov-12 4:28 
GeneralRe: Keeps returning NullReferenceException PinmemberV.21-Nov-12 4:31 
QuestionValidate XML file against rule in db Pinmemberrahul.net1120-Nov-12 23:29 
AnswerRe: Validate XML file against rule in db PinmemberPIEBALDconsult21-Nov-12 8:07 
GeneralRe: Validate XML file against rule in db Pinmemberrahul.net1116-Jan-13 21:01 
QuestionHow to set the distance between checkbox and text in using TreeView ? Pinmembertaibc20-Nov-12 23:26 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 22 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid