I have to develop a application using Asp.Net and VB.Net in .Net 1.1.
My aim is that ,I have one CSV File i want to read the CSV file and bulk insert into Oracle Database.
I use Batch file which contain
In CTL file contains the table name and the executable CSV file Path.
In c# of .Net 2005 is working fine.
If i double click on the Batch file then also data inserting into the table.
Both the case is fine but same thing i write in VB.Net.
The code is follows
' ******** Data moving from CSV file to TMP table ************/
Try
Dim startInfo As ProcessStartInfo = New ProcessStartInfo(Server.MapPath("~") + "/BatchFile/BATCH.BAT", "Command")
startInfo.WorkingDirectory = Server.MapPath("~") + "/BatchFile"
startInfo.CreateNoWindow = True
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
startInfo.UseShellExecute = True
Dim batchExecute As Process = New Process
batchExecute.StartInfo = startInfo
If (batchExecute.Start()) Then
batchExecute.WaitForExit()
lblMessage.Text = "Data moved successfully"
End If
Catch csvEX As Exception
lblMessage.Text = csvEX.Message
End Try
No error is coming but no data is inserting into database’s table.
'Data moving from CSV file to TMP table
Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(Server.MapPath("~") + "/BatchFile/BATCHUPLOAD.BAT", "Command")
startInfo.WorkingDirectory = Server.MapPath("~") + "/BatchFile"
startInfo.CreateNoWindow = True
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
startInfo.UseShellExecute = True
Dim batchExecute As System.Diagnostics.Process = New System.Diagnostics.Process
batchExecute.StartInfo = startInfo
If (batchExecute.Start()) Then
From this line it throws Access is denied error.
StackTrace " at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at seg1step.xx_import_xml_specs.btnUpload_Click(Object sender, EventArgs e) in D:\\Web\\mhe1stepQA\\xx_import_xml_specs.aspx.vb:line 120" String
Anyone can help me.
But if i go to folder and double click on BATCHUPLOAD.BAT file.Then it is working.Also, I developed it in c#.There is working but in VB.net it is not working.
Any help.Today is my delivery.( beacuse i did it in c# but in VB.net it gives this issue).
It is not a good idea to start a batch file (or any other process for that matter) from within a web page. In fact, I believe that your problems may be related to very sensible security settings within .NET which will not by default allow you to spawn new processes.
If you have already developed the “bulk inserter” in C#, why don’t you just refactor it so that the insertion logic can be called from the web page without starting external processes.
However, if this is a lot of data you will still have issues such as timeouts etc. In that case you are probably better off queuing up requests (using MSMQ or some database table as a poor-man’s queue) and having an external process check the queue continuously (blocking MSMQ calls ) or polling the table.
If you need instant handling and you cannot use queues for some reason, an alternative may be to queue up a WorkItem. A WorkItem will be scheduled by IIS to run asap. Note, that it will occupy a dispatcher thread for the duration of the processing. You could issue a “ticket” to the requester can use Ajax callbacks or “meta” redirects to poll for WorkItem completion.