Click here to Skip to main content
11,706,979 members (60,757 online)
   

C#

 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
Eddy Vluggen21-Nov-12 13:40
memberEddy Vluggen21-Nov-12 13:40 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-321-Nov-12 13:52
memberC-P-User-321-Nov-12 13:52 
SuggestionRe: Automatically Compiler Generated Unique Constants ? Pin
Eddy Vluggen21-Nov-12 13:55
memberEddy Vluggen21-Nov-12 13:55 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-321-Nov-12 14:52
memberC-P-User-321-Nov-12 14:52 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-321-Nov-12 15:03
memberC-P-User-321-Nov-12 15:03 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-321-Nov-12 15:01
memberC-P-User-321-Nov-12 15:01 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
PIEBALDconsult21-Nov-12 16:27
memberPIEBALDconsult21-Nov-12 16:27 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
Eddy Vluggen21-Nov-12 21:08
memberEddy Vluggen21-Nov-12 21:08 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
Richard MacCutchan21-Nov-12 22:01
mvpRichard MacCutchan21-Nov-12 22:01 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-322-Nov-12 14:22
memberC-P-User-322-Nov-12 14:22 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
Richard MacCutchan22-Nov-12 23:24
mvpRichard MacCutchan22-Nov-12 23:24 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
BobJanova22-Nov-12 23:29
memberBobJanova22-Nov-12 23:29 
GeneralRe: Automatically Compiler Generated Unique Constants ? Pin
C-P-User-323-Nov-12 4:43
memberC-P-User-323-Nov-12 4:43 
QuestionDataGridView doesn't appear on screen Pin
RickSharp21-Nov-12 12:44
memberRickSharp21-Nov-12 12: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 Pin
Eddy Vluggen21-Nov-12 13:17
memberEddy Vluggen21-Nov-12 13:17 
GeneralRe: DataGridView doesn't appear on screen Pin
RickSharp21-Nov-12 13:27
memberRickSharp21-Nov-12 13:27 
GeneralRe: DataGridView doesn't appear on screen Pin
Eddy Vluggen21-Nov-12 13:42
memberEddy Vluggen21-Nov-12 13:42 
QuestionTextbox help! Pin
Kurac121-Nov-12 11:18
memberKurac121-Nov-12 11:18 
AnswerRe: Textbox help! Pin
Mycroft Holmes21-Nov-12 12:01
memberMycroft Holmes21-Nov-12 12:01 
QuestionSpecialized List Sorting question Pin
NuclearMan8521-Nov-12 7:12
memberNuclearMan8521-Nov-12 7:12 
AnswerRe: Specialized List Sorting question Pin
Richard Deeming21-Nov-12 8:03
memberRichard Deeming21-Nov-12 8:03 
AnswerRe: Specialized List Sorting question Pin
SledgeHammer0121-Nov-12 8:06
memberSledgeHammer0121-Nov-12 8:06 
AnswerRe: Specialized List Sorting question Pin
Richard Deeming21-Nov-12 8:32
memberRichard Deeming21-Nov-12 8:32 
AnswerRe: Specialized List Sorting question Pin
PIEBALDconsult21-Nov-12 8:57
memberPIEBALDconsult21-Nov-12 8:57 
AnswerRe: Specialized List Sorting question Pin
BobJanova21-Nov-12 22:50
memberBobJanova21-Nov-12 22:50 
QuestionWinForms Class Design Pin
Member 961929521-Nov-12 6:43
memberMember 961929521-Nov-12 6:43 
AnswerRe: WinForms Class Design Pin
Richard MacCutchan21-Nov-12 7:15
mvpRichard MacCutchan21-Nov-12 7:15 
GeneralRe: WinForms Class Design Pin
Matt U.21-Nov-12 8:16
memberMatt U.21-Nov-12 8:16 
GeneralRe: WinForms Class Design Pin
Richard MacCutchan21-Nov-12 8:56
mvpRichard MacCutchan21-Nov-12 8:56 
GeneralRe: WinForms Class Design Pin
Matt U.21-Nov-12 8:59
memberMatt U.21-Nov-12 8:59 
GeneralRe: WinForms Class Design Pin
Richard MacCutchan21-Nov-12 9:06
mvpRichard MacCutchan21-Nov-12 9:06 
GeneralRe: WinForms Class Design Pin
Matt U.21-Nov-12 9:21
memberMatt U.21-Nov-12 9:21 
GeneralRe: WinForms Class Design Pin
PIEBALDconsult21-Nov-12 10:27
memberPIEBALDconsult21-Nov-12 10:27 
AnswerRe: WinForms Class Design Pin
PIEBALDconsult21-Nov-12 9:07
memberPIEBALDconsult21-Nov-12 9:07 
QuestionUplaod Article To Codeproject Pin
katlegoEmmnanuelNkosi21-Nov-12 3:44
groupkatlegoEmmnanuelNkosi21-Nov-12 3:44 
AnswerRe: Uplaod Article To Codeproject Pin
PIEBALDconsult21-Nov-12 3:48
memberPIEBALDconsult21-Nov-12 3:48 
AnswerRe: Uplaod Article To Codeproject Pin
Richard MacCutchan21-Nov-12 4:34
mvpRichard MacCutchan21-Nov-12 4:34 
QuestionPrint Crystal Report in c# Using Access Database? Pin
kashifjaat21-Nov-12 2:09
memberkashifjaat21-Nov-12 2:09 
QuestionGenerate Morse Code Sound Pin
long dao21-Nov-12 1:24
memberlong dao21-Nov-12 1:24 
AnswerRe: Generate Morse Code Sound Pin
Pete O'Hanlon21-Nov-12 1:45
protectorPete O'Hanlon21-Nov-12 1:45 
GeneralRe: Generate Morse Code Sound Pin
long dao21-Nov-12 1:54
memberlong dao21-Nov-12 1:54 
GeneralRe: Generate Morse Code Sound Pin
Pete O'Hanlon21-Nov-12 2:05
protectorPete O'Hanlon21-Nov-12 2:05 
QuestionKeeps returning NullReferenceException Pin
MacUseless20-Nov-12 23:08
memberMacUseless20-Nov-12 23:08 
SuggestionRe: Keeps returning NullReferenceException Pin
V.21-Nov-12 3:25
memberV.21-Nov-12 3:25 
GeneralRe: Keeps returning NullReferenceException Pin
MacUseless21-Nov-12 3:28
memberMacUseless21-Nov-12 3:28 
GeneralRe: Keeps returning NullReferenceException Pin
V.21-Nov-12 3:31
memberV.21-Nov-12 3:31 
QuestionValidate XML file against rule in db Pin
rahul.net1120-Nov-12 22:29
memberrahul.net1120-Nov-12 22:29 
AnswerRe: Validate XML file against rule in db Pin
PIEBALDconsult21-Nov-12 7:07
memberPIEBALDconsult21-Nov-12 7:07 
GeneralRe: Validate XML file against rule in db Pin
rahul.net1116-Jan-13 20:01
memberrahul.net1116-Jan-13 20:01 
QuestionHow to set the distance between checkbox and text in using TreeView ? Pin
taibc20-Nov-12 22:26
membertaibc20-Nov-12 22: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
Web02 | 2.8.150819.1 | Last Updated 30 Aug 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid