Click here to Skip to main content
15,899,126 members
Home / Discussions / C#
   

C#

 
AnswerRe: Double click custom controls Pin
Jon Henry2-Aug-09 1:44
Jon Henry2-Aug-09 1:44 
QuestionConnecting to MySQL from PC Pin
MarkB77730-Jul-09 2:08
MarkB77730-Jul-09 2:08 
AnswerRe: Connecting to MySQL from PC Pin
stancrm30-Jul-09 2:25
stancrm30-Jul-09 2:25 
AnswerRe: Connecting to MySQL from PC Pin
spalanivel30-Jul-09 2:34
spalanivel30-Jul-09 2:34 
AnswerRe: Connecting to MySQL from PC Pin
Dave Kreskowiak30-Jul-09 6:31
mveDave Kreskowiak30-Jul-09 6:31 
GeneralRe: Connecting to MySQL from PC Pin
EliottA30-Jul-09 7:26
EliottA30-Jul-09 7:26 
GeneralRe: Connecting to MySQL from PC Pin
MarkB77730-Jul-09 15:20
MarkB77730-Jul-09 15:20 
QuestionHow to Read CSV file in Readonly mode and Populate dataset? Pin
Tridip Bhattacharjee30-Jul-09 2:08
professionalTridip Bhattacharjee30-Jul-09 2:08 
i am reading a CSV file and getting error that file is in use. i am trying to read CSV file by ado.net and fill the dataset.

my code is as follows :-
---------------------------
DataTable dt = null;
bool flag;
DataSet objDS = new DataSet();
OdbcConnection mobjCon = null;

try
{
string mstrConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + Path.GetDirectoryName(strFilePath) + ";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string strQuery;
mobjCon = new OdbcConnection(mstrConnectionString.Trim());
mobjCon.Open();
strQuery = "select * from [" + Path.GetFileName(strFilePath) + "]";
OdbcDataAdapter mobjAdapter = new OdbcDataAdapter(strQuery, mobjCon);
mobjAdapter.Fill(objDS, "phone");
CreateTableInDatabase(tableName);
using (SqlBulkCopy bc = new SqlBulkCopy(Business.ProgramConnections.OrcsConnectionString))
{
bc.DestinationTableName = tableName;
bc.WriteToServer(objDS.Tables["phone"]);
bc.Close();
flag = true;
}

if (flag)
{
mobjCon.Dispose();
FetchData(tableName);
}
}
catch (Exception objEx)
{
throw objEx;
}
finally
{
if (mobjCon.State == ConnectionState.Open)
{
mobjCon.Close();
}
}

in this above way i am trying to fill dataset with data from CSV file.
i am getting error because file is opened by another application.
i want that if the file is opened by another application inspite of i want to read this CSV file and populate my dataset. so please anybody rectify my code to read the locked CSV file and populate the dataset.

if possible give me a sample code by which i can read any locked CSV file, i mean in use CSV file and populate my dataset.please help me this is urgent.


Thanks in advance

tbhattacharjee

AnswerRe: How to Read CSV file in Readonly mode and Populate dataset? Pin
Dave Kreskowiak30-Jul-09 6:29
mveDave Kreskowiak30-Jul-09 6:29 
GeneralRe: How to Read CSV file in Readonly mode and Populate dataset? Pin
Tridip Bhattacharjee30-Jul-09 18:35
professionalTridip Bhattacharjee30-Jul-09 18:35 
GeneralRe: How to Read CSV file in Readonly mode and Populate dataset? Pin
Dave Kreskowiak31-Jul-09 13:16
mveDave Kreskowiak31-Jul-09 13:16 
QuestionException use instead of validation Pin
Raybarg30-Jul-09 1:14
professionalRaybarg30-Jul-09 1:14 
QuestionStatic constructor Pin
erfgerfgerger30-Jul-09 1:07
erfgerfgerger30-Jul-09 1:07 
AnswerRe: Static constructor Pin
Ashfield30-Jul-09 1:29
Ashfield30-Jul-09 1:29 
GeneralRe: Static constructor Pin
erfgerfgerger30-Jul-09 1:34
erfgerfgerger30-Jul-09 1:34 
GeneralRe: Static constructor Pin
Luc Pattyn30-Jul-09 2:04
sitebuilderLuc Pattyn30-Jul-09 2:04 
GeneralRe: Static constructor Pin
Ashfield30-Jul-09 8:28
Ashfield30-Jul-09 8:28 
AnswerRe: Static constructor PinPopular
DaveyM6930-Jul-09 1:33
professionalDaveyM6930-Jul-09 1:33 
AnswerRe: Static constructor Pin
Daniel Grunwald30-Jul-09 1:49
Daniel Grunwald30-Jul-09 1:49 
GeneralRe: Static constructor Pin
erfgerfgerger30-Jul-09 2:01
erfgerfgerger30-Jul-09 2:01 
GeneralRe: Static constructor Pin
Daniel Grunwald30-Jul-09 2:04
Daniel Grunwald30-Jul-09 2:04 
GeneralRe: Static constructor Pin
erfgerfgerger30-Jul-09 2:07
erfgerfgerger30-Jul-09 2:07 
GeneralRe: Static constructor Pin
PIEBALDconsult30-Jul-09 4:28
mvePIEBALDconsult30-Jul-09 4:28 
QuestionExtreme right click on the scollbar any event? Pin
spalanivel30-Jul-09 0:14
spalanivel30-Jul-09 0:14 
AnswerRe: Extreme right click on the scollbar any event? Pin
Alan N30-Jul-09 3:15
Alan N30-Jul-09 3: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.