I have used the code from below link:
http://www.dotnetspider.com/resources/3069-How-insert-e-data-from-excel-Database.aspx
It works well in my personal PC and i was able to insert all data from CSV to Oracle table.
But when i implement the same in my office machine. iam not getting any output or error message.
i get a cmd.exe window and it exists after few seconds. Nothing happens after this.
Looks like a permission problem. I am stuck, kindly help.
Is there any other possibility to execute sqlldr.exe directly?
It looks like there are no articles on this in C# corner. Somebody pls help.
Thanks in advance.
vinay C D MPosted Feb 28, 2009, 8:44 AM
Hi,
Sorry for the late reply, I was away for a week.
Jan,
Thanks for the links. I think i have already tried the first one. Let me try the second one and give you comments.
1. I am able to access the database manually without any trouble.
2. My id have admin rights and by the way how to check aspnet user have all rights or not.
Vijaya,
Could you throw me some light on what is external table. Any example links will do.
My machine have sqlldr and i was able to load the data in to oracle table very well from the command prompt
like this 'sqlldr xyz/[email protected] control=auto.ctl'.
I am trying to do the same think with C# but not successful.
I need to get 40,000 records from csv file in to oracle table. Does external tables will be reliable and fast?
Vijaya KadiyalaPosted Feb 23, 2009, 8:40 PM
Hi
Instead of using SQLLDR why dont you use external tables?? this way you dont have to load any file?? Btw the machine where you are running does it has sqlldr?? can you try using from command and try loading the file and tell me is this works or not??
Thanks -- Vijaya Kadiyala
Jan MontanoPosted Feb 23, 2009, 6:52 PM
Here's another way of executing it. This link provides 2 versions. Try both and let's just hope for the best.
1. Also, have you tried to access your database manually from your office machine?
2. Is the logged-on user in your office machine an administrator?
vinay C D MPosted Feb 20, 2009, 7:35 AM
Well, i tried that too. But still the same.
Control is not passing to exception block at all bcos of no errors.
Is there any other way i could use sqlldr or how to troubleshoot this problem?
Jan MontanoPosted Feb 20, 2009, 12:20 AM
catch
{
throw;
}
Then try to run it again.
vinay C D MPosted Feb 19, 2009, 7:44 AM
Thanks for the reply jan.
I have debugged the code many times. it was not throwing any exception, the code works well but it is not performing the task as intended.
Here is the function i am using:
private void UploadDatabase(string strCSVPath, string strLoaderFile, string strLogFile)
{
string strCmd, strSQLLoader;
strCmd = "sqlldr XYZ/[email protected] control=" + strLoaderFile + " LOG=" + strLogFile;
System.IO.DirectoryInfo di;
try
{
System.Diagnostics.ProcessStartInfo cmdProcessInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
di = new DirectoryInfo(strCSVPath);
strSQLLoader = "";
strSQLLoader += "LOAD DATA INFILE '" + strCSVPath.ToString().Trim() + "' INSERT INTO TABLE TEMP_ENTITLE FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'(PO,Desc,CommodityName,Manuf,Quantity,Amount)";
StreamWriter writer = new StreamWriter(strLoaderFile);
writer.WriteLine(strSQLLoader);
writer.Flush();
writer.Close();
cmdProcessInfo.RedirectStandardInput = true;
cmdProcessInfo.RedirectStandardOutput = true;
cmdProcessInfo.UseShellExecute = false;
// Start the procses.
System.Diagnostics.Process pro = System.Diagnostics.Process.Start(cmdProcessInfo);
// Issue the dir command.
pro.StandardInput.WriteLine(strCmd);
pro.StandardInput.WriteLine("exit");
// Read all the output generated from it.
string strOutput;
strOutput = pro.StandardOutput.ReadToEnd();
pro.Dispose();
}
catch
{
return;
}
finally { }
}
While debugging, I figured out that in stroutput iam getting as this:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
c:\Program Files\Microsoft Visual Studio 8\Common7\IDE>sqlldr XYZ/[email protected] control=D:\SWIFT\POC_20090210\POc_Working folder\AUTO1.ctl LOG=D:\SWIFT\POC_20090210\POc_Working folder\LOGS.log
c:\Program Files\Microsoft Visual Studio 8\Common7\IDE>exit
Jan MontanoPosted Feb 18, 2009, 9:45 PM
But have you tried to catch the exception of the code. I suggest you debug the code in your office machine and catch the exception.
Without the specific error message, we won't be able to do much help.