Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: Wrap around Single Dimension array Pin
Blade24323-Apr-08 17:06
Blade24323-Apr-08 17:06 
GeneralRe: Wrap around Single Dimension array Pin
Jordanwb24-Apr-08 2:08
Jordanwb24-Apr-08 2:08 
GeneralRe: Wrap around Single Dimension array Pin
Guffa23-Apr-08 21:09
Guffa23-Apr-08 21:09 
Questionusing of dataset generated , dataset.xsc or .xss Pin
Knowledgestudent23-Apr-08 11:14
Knowledgestudent23-Apr-08 11:14 
GeneralProperly disconnecting and shutting down a socket. [modified] Pin
Jordanwb23-Apr-08 10:26
Jordanwb23-Apr-08 10:26 
GeneralRe: Properly disconnecting and shutting down a socket. Pin
Gareth H23-Apr-08 12:55
Gareth H23-Apr-08 12:55 
GeneralRe: Properly disconnecting and shutting down a socket. Pin
Jordanwb25-Apr-08 9:11
Jordanwb25-Apr-08 9:11 
GeneralImporting a csv Pin
BraveKnightFSJ23-Apr-08 10:07
BraveKnightFSJ23-Apr-08 10:07 
Hello,

I am trying to import a csv file. I know my code works because I have imported may files. but my problem is if the file name has a ' or a second . in the name I get a Syntax error in FROM clause.

OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source={0};Extended Properties={1}Text;Excel 8.0;HDR=No;{2}",
System.IO.Path.GetDirectoryName(FileName), (char)34, (char)34);
conn.open();
string SchemeFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FileName),
"schema.ini");
if (File.Exists(SchemeFile))
File.Delete(SchemeFile);
using (FileStream SchemaStream = new FileStream(SchemeFile, FileMode.CreateNew))
{
using (StreamWriter writer = new StreamWriter(SchemaStream))
{
writer.AutoFlush = true;
writer.WriteLine("[" + System.IO.Path.GetFileName(FileName) + "]");
writer.WriteLine("ColNameHeader=False");
writer.WriteLine("Format=Delimited(,)");
writer.WriteLine("CharacterSet=ANSI");
writer.WriteLine("Col1=Code text width 255");
writer.WriteLine("Col2=Description text width 255");
writer.WriteLine("Col3=UnitOfMeasure text width 255");
writer.WriteLine("Col4=Price text width 255");
}
SchemaStream.Close();
}

CommandText = String.Format("SELECT * FROM {0}", System.IO.Path.GetFullPath(FileName));
OleDbDataAdapter da = new OleDbDataAdapter(CommandText, conn);
DataTable MyTable = new DataTable();
da.Fill(MyTable);

it crashes on the last line the da.fill

Any help would be wonderful

Thanks
GeneralRe: Importing a csv Pin
Christian Graus23-Apr-08 10:25
protectorChristian Graus23-Apr-08 10:25 
GeneralRe: Importing a csv Pin
BraveKnightFSJ23-Apr-08 12:29
BraveKnightFSJ23-Apr-08 12:29 
GeneralRe: Importing a csv Pin
Christian Graus23-Apr-08 12:38
protectorChristian Graus23-Apr-08 12:38 
GeneralRe: Importing a csv Pin
BraveKnightFSJ24-Apr-08 10:17
BraveKnightFSJ24-Apr-08 10:17 
QuestionSQL Server Authentication Pin
aecordoba23-Apr-08 9:33
aecordoba23-Apr-08 9:33 
GeneralRe: SQL Server Authentication Pin
Sam Xavier24-Apr-08 21:05
Sam Xavier24-Apr-08 21:05 
GeneralRe: SQL Server Authentication Pin
aecordoba25-Apr-08 3:47
aecordoba25-Apr-08 3:47 
GeneralRe: SQL Server Authentication Pin
Sam Xavier28-Apr-08 20:07
Sam Xavier28-Apr-08 20:07 
GeneralXML file resturctued with XSL style sheet Pin
zaboboa23-Apr-08 9:26
zaboboa23-Apr-08 9:26 
GeneralRe: XML file resturctued with XSL style sheet Pin
led mike23-Apr-08 9:33
led mike23-Apr-08 9:33 
GeneralRe: XML file resturctued with XSL style sheet Pin
zaboboa23-Apr-08 10:10
zaboboa23-Apr-08 10:10 
GeneralRe: XML file resturctued with XSL style sheet Pin
zaboboa23-Apr-08 10:11
zaboboa23-Apr-08 10:11 
QuestionIVR System Pin
KBM7323-Apr-08 7:08
KBM7323-Apr-08 7:08 
NewsRe: IVR System Pin
carbon_golem23-Apr-08 8:11
carbon_golem23-Apr-08 8:11 
GeneralRe: IVR System Pin
MumbleB23-Apr-08 8:37
MumbleB23-Apr-08 8:37 
Questionexception handling for another program, is it possible in c#? Pin
Cptkli23-Apr-08 6:46
Cptkli23-Apr-08 6:46 
AnswerRe: exception handling for another program, is it possible in c#? Pin
Dave Kreskowiak23-Apr-08 10:05
mveDave Kreskowiak23-Apr-08 10:05 

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.