I have a requirement where a user upload a CSV file to the server through an
ASP.NET page. After the file is uploaded the ASP.NET page then has to upload
the contents of this file into an Oracle table. After the upload is complete
the ASP.NET page has to call an Oracle stored procedure to process the data.
All this has to be done in one go.
Here is a what I did.
1. Created a simple ASP.NET page which provides the user with a file upload
element to select the CSV file to uploaded. One the user selects the file he
clicks on the upload button.
2. Upon clicking the upload button, I upload the file file and save it into
a particular folder on the server. This folder also contains a Oracle SQL
Loader control file (*.ctl).
3. After the upload of the file, I launch a shell command to execute the
sqlldr.exe to bulk load the data to the oracle table.
4. Once the bulk load is complete, if there are no errors then I call a
stored procedure through the OracleClient.
All this work fine in the CSV file contains upto 4500 records. Each record
is made up of 2 columns, 1) a five digit code and 2) an numeric value between
0 and 10000000.
The problem occurs when the number of records exceed more than 5000, the
process hangs after loading abt 4700 records. It shows the SQLLDR process as
runing in the task manager on the server. The browers shows the progress bar
for about 3-5 mins before throwing a page not found error. I tried uploading
by directly calling sqlldr, the file with 5000 records took less than 5
seconds to complete load.
Splitting the file into multiple files is not an option. I have to do in one
go.
Here is code I have used to launch the external process.
Code for on click of upload button
----------------------------------
private void UploadFile()
{
int nBufferLen = 4096;
if(fileReserve. PostedFile != null)
{
filePosted = fileReserve.Pos tedFile;
nContentLength = filePosted.Cont entLength;
byte[] buffer = new byte[nBufferLen];
int nBytesRead;
String strVirDirPath = Server.MapPath( Request.Applica tionPath);
strPath = strVirDirPath + // folder where the file needs to uploaded to
if(File.Exists( strPath))
{
File.Delete(str Path);
}
FileStream newFile = new FileStream(strP ath, FileMode.Create );
nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen);
do
{
newFile.Write(b uffer, 0, nBytesRead);
nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen);
}while(nBytesRe ad != 0);
newFile.Close() ;
retval = UploadData(strP ath); // code below
}
}
private bool UploadData(Stri ng FileName)
{
RegistryKey objRegKeyOracle = null;
String strTemp = String.Empty;
String strSqlLoaderPat h = String.Empty;
String strUserID = String.Empty;
String strPassword = String.Empty;
String strDatabase = String.Empty;
String strControlFile = String.Empty;
String strConnectionSt ring = String.Empty;
String strBadFile = String.Empty;
bool blnSqlLoaderExi sts = false;
objRegKeyOracle = Registry.LocalM achine.OpenSubK ey(@"SOFTWARE\O RACLE");
if(objRegKeyOra cle != null)
{
strSqlLoaderPat h = (String)objRegK eyOracle.GetVal ue("ORACLE_HOME ") +
@"\bin\sqlldr.e xe";
blnSqlLoaderExi sts = File.Exists(str SqlLoaderPath);
}
objRegKeyOracle .Close();
if(!blnSqlLoade rExists)
{
throw new exception
}
strTemp = DBConnection.Ge tConnectionStri ng(m_objCurrent User.Region);
strUserID = GetValue(strTem p, "USER ID");
strPassword = GetValue(strTem p, "PASSWORD") ;
strDatabase = GetValue(strTem p, "DATA SOURCE");
strControlFile = Server.MapPath(//Virtual path to control file);
strBadFile = Server.MapPath(// virtual path to where the bad file has to be
created if SQLLDR fails);
if(File.Exists( strBadFile))
{
File.Delete(str BadFile);
}
strConnectionSt ring = "userid=" + strUserID + "@" + strDatabase + "/" +
strPassword + " control=" + strControlFile + " data=" + FileName;
String strShellCmd = "sqlldr " + strConnectionSt ring;
String strWorkingDir = strControlFile. Substring(0,
strControlFile. LastIndexOf("\\ "));
System.Diagnost ics.ProcessStar tInfo objPSI = new
System.Diagnost ics.ProcessStar tInfo("cmd.exe" );
objPSI.UseShell Execute = false;
objPSI.Redirect StandardOutput = true;
objPSI.Redirect StandardInput = true;
objPSI.Redirect StandardError = true;
objPSI.WorkingD irectory = strWorkingDir;
System.Diagnost ics.Process proc = System.Diagnost ics.Process.Sta rt(objPSI);
// Attach the output for reading
System.IO.Strea mReader sOut = proc.StandardOu tput;
// Attach the in for writing
System.IO.Strea mWriter sIn = proc.StandardIn put;
// Write command to standard input
sIn.WriteLine(s trShellCmd);
// Exit Command
sIn.WriteLine(" EXIT");
proc.WaitForExi t();
// Close the process
proc.Close();
// Read the sOut to a string.
string results = sOut.ReadToEnd( ).Trim();
// Close the io Streams;
sIn.Close();
sOut.Close();
return true;
}
--
Regards,
Matt. 2 2188
Matt:
Is there any chance the sqlldr.exe might be waiting for user input of
some sort?
Are then any switches you can pass the process to get more diagnostic
information or log to a file?
In short, nothing looks wrong with the code - you'll have to gather
some more info about what is happening.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 5 May 2005 13:46:04 -0700, "Matt"
<Ma**@discussio ns.microsoft.co m> wrote: I have a requirement where a user upload a CSV file to the server through an ASP.NET page. After the file is uploaded the ASP.NET page then has to upload the contents of this file into an Oracle table. After the upload is complete the ASP.NET page has to call an Oracle stored procedure to process the data. All this has to be done in one go.
Here is a what I did. 1. Created a simple ASP.NET page whic
h provides the user with a file uploadelement to select the CSV file to uploaded. One the user selects the file he clicks on the upload button. 2. Upon clicking the upload button, I upload the file file and save it into a particular folder on the server. This folder also contains a Oracle SQL Loader control file (*.ctl). 3. After the upload of the file, I launch a shell command to execute the sqlldr.exe to bulk load the data to the oracle table. 4. Once the bulk load is complete, if there are no errors then I call a stored procedure through the OracleClient.
All this work fine in the CSV file contains upto 4500 records. Each record is made up of 2 columns, 1) a five digit code and 2) an numeric value between 0 and 10000000.
The problem occurs when the number of records exceed more than 5000, the process hangs after loading abt 4700 records. It shows the SQLLDR process as runing in the task manager on the server. The browers shows the progress bar for about 3-5 mins before throwing a page not found error. I tried uploading by directly calling sqlldr, the file with 5000 records took less than 5 seconds to complete load.
Splitting the file into multiple files is not an option. I have to do in one go.
Here is code I have used to launch the external process.
Code for on click of upload button ---------------------------------- private void UploadFile() { int nBufferLen = 4096;
if(fileReserve. PostedFile != null) { filePosted = fileReserve.Pos tedFile; nContentLength = filePosted.Cont entLength; byte[] buffer = new byte[nBufferLen]; int nBytesRead;
String strVirDirPath = Server.MapPath( Request.Applica tionPath);
strPath = strVirDirPath + // folder where the file needs to uploaded to if(File.Exists( strPath)) { File.Delete(str Path); } FileStream newFile = new FileStream(strP ath, FileMode.Create );
nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen); do { newFile.Write(b uffer, 0, nBytesRead); nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen); }while(nBytesRe ad != 0);
newFile.Close() ;
retval = UploadData(strP ath); // code below
} }
private bool UploadData(Stri ng FileName) { RegistryKey objRegKeyOracle = null;
String strTemp = String.Empty; String strSqlLoaderPat h = String.Empty; String strUserID = String.Empty; String strPassword = String.Empty; String strDatabase = String.Empty; String strControlFile = String.Empty; String strConnectionSt ring = String.Empty; String strBadFile = String.Empty;
bool blnSqlLoaderExi sts = false;
objRegKeyOracle = Registry.LocalM achine.OpenSubK ey(@"SOFTWARE\O RACLE");
if(objRegKeyOra cle != null) { strSqlLoaderPat h = (String)objRegK eyOracle.GetVal ue("ORACLE_HOME ") + @"\bin\sqlldr. exe"; blnSqlLoaderExi sts = File.Exists(str SqlLoaderPath); }
objRegKeyOracle .Close();
if(!blnSqlLoade rExists) { throw new exception }
strTemp = DBConnection.Ge tConnectionStri ng(m_objCurrent User.Region);
strUserID = GetValue(strTem p, "USER ID"); strPassword = GetValue(strTem p, "PASSWORD") ; strDatabase = GetValue(strTem p, "DATA SOURCE");
strControlFile = Server.MapPath(//Virtual path to control file); strBadFile = Server.MapPath(// virtual path to where the bad file has to be created if SQLLDR fails);
if(File.Exists( strBadFile)) { File.Delete(str BadFile); }
strConnectionSt ring = "userid=" + strUserID + "@" + strDatabase + "/" + strPassword + " control=" + strControlFile + " data=" + FileName;
String strShellCmd = "sqlldr " + strConnectionSt ring;
String strWorkingDir = strControlFile. Substring(0, strControlFile .LastIndexOf("\ \"));
System.Diagnost ics.ProcessStar tInfo objPSI = new System.Diagnos tics.ProcessSta rtInfo("cmd.exe "); objPSI.UseShell Execute = false; objPSI.Redirect StandardOutput = true; objPSI.Redirect StandardInput = true; objPSI.Redirect StandardError = true;
objPSI.WorkingD irectory = strWorkingDir;
System.Diagnost ics.Process proc = System.Diagnost ics.Process.Sta rt(objPSI);
// Attach the output for reading System.IO.Strea mReader sOut = proc.StandardOu tput;
// Attach the in for writing System.IO.Strea mWriter sIn = proc.StandardIn put;
// Write command to standard input sIn.WriteLine(s trShellCmd);
// Exit Command sIn.WriteLine(" EXIT");
proc.WaitForExi t();
// Close the process proc.Close();
// Read the sOut to a string. string results = sOut.ReadToEnd( ).Trim();
// Close the io Streams; sIn.Close(); sOut.Close();
return true; }
Sorry for the late response...
SQLLDR is not waiting for any user input... However I found another piece of
code which actually worked. I did not have too much time to research. It is
more or less the same as the code below, but instead of lauching a command
prompt window and then firing the sqlldr command, i called sqlldr directly.
Thank again.
--
Regards,
Matt.
"Scott Allen" wrote: Matt:
Is there any chance the sqlldr.exe might be waiting for user input of some sort?
Are then any switches you can pass the process to get more diagnostic information or log to a file?
In short, nothing looks wrong with the code - you'll have to gather some more info about what is happening.
-- Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 5 May 2005 13:46:04 -0700, "Matt" <Ma**@discussio ns.microsoft.co m> wrote:
I have a requirement where a user upload a CSV file to the server through an ASP.NET page. After the file is uploaded the ASP.NET page then has to upload the contents of this file into an Oracle table. After the upload is complete the ASP.NET page has to call an Oracle stored procedure to process the data. All this has to be done in one go.
Here is a what I did. 1. Created a simple ASP.NET page whic h provides the user with a file uploadelement to select the CSV file to uploaded. One the user selects the file he clicks on the upload button. 2. Upon clicking the upload button, I upload the file file and save it into a particular folder on the server. This folder also contains a Oracle SQL Loader control file (*.ctl). 3. After the upload of the file, I launch a shell command to execute the sqlldr.exe to bulk load the data to the oracle table. 4. Once the bulk load is complete, if there are no errors then I call a stored procedure through the OracleClient.
All this work fine in the CSV file contains upto 4500 records. Each record is made up of 2 columns, 1) a five digit code and 2) an numeric value between 0 and 10000000.
The problem occurs when the number of records exceed more than 5000, the process hangs after loading abt 4700 records. It shows the SQLLDR process as runing in the task manager on the server. The browers shows the progress bar for about 3-5 mins before throwing a page not found error. I tried uploading by directly calling sqlldr, the file with 5000 records took less than 5 seconds to complete load.
Splitting the file into multiple files is not an option. I have to do in one go.
Here is code I have used to launch the external process.
Code for on click of upload button ---------------------------------- private void UploadFile() { int nBufferLen = 4096;
if(fileReserve. PostedFile != null) { filePosted = fileReserve.Pos tedFile; nContentLength = filePosted.Cont entLength; byte[] buffer = new byte[nBufferLen]; int nBytesRead;
String strVirDirPath = Server.MapPath( Request.Applica tionPath);
strPath = strVirDirPath + // folder where the file needs to uploaded to if(File.Exists( strPath)) { File.Delete(str Path); } FileStream newFile = new FileStream(strP ath, FileMode.Create );
nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen); do { newFile.Write(b uffer, 0, nBytesRead); nBytesRead = filePosted.Inpu tStream.Read(bu ffer,0, nBufferLen); }while(nBytesRe ad != 0);
newFile.Close() ;
retval = UploadData(strP ath); // code below
} }
private bool UploadData(Stri ng FileName) { RegistryKey objRegKeyOracle = null;
String strTemp = String.Empty; String strSqlLoaderPat h = String.Empty; String strUserID = String.Empty; String strPassword = String.Empty; String strDatabase = String.Empty; String strControlFile = String.Empty; String strConnectionSt ring = String.Empty; String strBadFile = String.Empty;
bool blnSqlLoaderExi sts = false;
objRegKeyOracle = Registry.LocalM achine.OpenSubK ey(@"SOFTWARE\O RACLE");
if(objRegKeyOra cle != null) { strSqlLoaderPat h = (String)objRegK eyOracle.GetVal ue("ORACLE_HOME ") + @"\bin\sqlldr. exe"; blnSqlLoaderExi sts = File.Exists(str SqlLoaderPath); }
objRegKeyOracle .Close();
if(!blnSqlLoade rExists) { throw new exception }
strTemp = DBConnection.Ge tConnectionStri ng(m_objCurrent User.Region);
strUserID = GetValue(strTem p, "USER ID"); strPassword = GetValue(strTem p, "PASSWORD") ; strDatabase = GetValue(strTem p, "DATA SOURCE");
strControlFile = Server.MapPath(//Virtual path to control file); strBadFile = Server.MapPath(// virtual path to where the bad file has to be created if SQLLDR fails);
if(File.Exists( strBadFile)) { File.Delete(str BadFile); }
strConnectionSt ring = "userid=" + strUserID + "@" + strDatabase + "/" + strPassword + " control=" + strControlFile + " data=" + FileName;
String strShellCmd = "sqlldr " + strConnectionSt ring;
String strWorkingDir = strControlFile. Substring(0, strControlFile .LastIndexOf("\ \"));
System.Diagnost ics.ProcessStar tInfo objPSI = new System.Diagnos tics.ProcessSta rtInfo("cmd.exe "); objPSI.UseShell Execute = false; objPSI.Redirect StandardOutput = true; objPSI.Redirect StandardInput = true; objPSI.Redirect StandardError = true;
objPSI.WorkingD irectory = strWorkingDir;
System.Diagnost ics.Process proc = System.Diagnost ics.Process.Sta rt(objPSI);
// Attach the output for reading System.IO.Strea mReader sOut = proc.StandardOu tput;
// Attach the in for writing System.IO.Strea mWriter sIn = proc.StandardIn put;
// Write command to standard input sIn.WriteLine(s trShellCmd);
// Exit Command sIn.WriteLine(" EXIT");
proc.WaitForExi t();
// Close the process proc.Close();
// Read the sOut to a string. string results = sOut.ReadToEnd( ).Trim();
// Close the io Streams; sIn.Close(); sOut.Close();
return true; }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Li |
last post by:
I have a windows form application (C#) that launches multiple external batch
files to do various installation tasks. I want to show some status on the
win form, say simply update the text on a Lable control, "task 1
starting...", "Task 1 completed.", etc.
However, the text for the label is not being updated/showed. I understand
that the window is not responding to the Paint event anymore, How do I work
around this?
I see programs...
|
by: TB |
last post by:
Hi all:
If you think that the following comments are absolute amateurish, then
please bear with me, or simply skip this thread.
A couple of months back I made the decision to initiate a gradual upgrade of
my web programming skills from Classic ASP / VBS to ASP.NET / VB.NET.
While the study of the language differences and all the new features in .NET
has so far not been a traumatic experience, I am a bit shell-schocked after
|
by: sir_alex |
last post by:
If i have to execute an external program (for example, in the frontend
that i created for convert, from ImageMagick) i have 2 possibilities: i
can call one function between the exec* family, or i can call the
system function: so, which in your opinion is the best? The only
difference that i know (but i may be in error) between these 2
functions is that the former doesn't return (so you have to create a
child process), but the latter...
|
by: jfigueiras |
last post by:
>I have a problem with the module subprocess!
As many other programs...
I'm not sure what you mean by "non-standard file descriptors". The
other program is free to open, read, write, etc any file he wants -
are you trying to trap any file operation it may want to do?
You *could* do such things -google for "code injection" and "API
hooking"- but I doubt it's what you really want.
|
by: Heikki Toivonen |
last post by:
We have successfully used a script to run external programs for several
years. Now we upgraded our Python to 2.5, and are hitting a mysterious
error.
The expected output from the sample script (see below) with 2.4 looks
like this:
ret
else
********************
| |
by: mats edvinsson |
last post by:
i have been up to creating an shortcut application but i dont know how to run external programs on a double click of an image.
i have put the image out and added a double click action so all i need now is a piece of code that run an external program
|
by: Ojas |
last post by:
Hi!,
I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under Command Prompt or
Browser or some other application?
Ojas.
|
by: pompeyoc |
last post by:
Hi. I was wondering if anyone out here knows if there is a limit to
the size of an external stored procedure? I am currently using VB
programs in Windows to call small COBOL stored procs residing in AIX
without any problems. This time, however, I am planning to have
another VB program call a COBOL stored proc that, in turn, calls other
COBOL programs via ordinary COBOL CALLs.
Any ideas?
|
by: Jimmy |
last post by:
Well, i know it may be a little non-python thing, however, I can think
of no place better to post this question :)
can anyone tell me, in python, how to obtain some information of a
running program?
paticularly, if i am playing some music in audacious or other media
player, how can i get the the name and some other info of current
playing song? It seems that audicious doesn't output on run-time
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |