如何在Vb.Net中使用SQLLoader [英] How to use SQLLoader in Vb.Net

查看:76
本文介绍了如何在Vb.Net中使用SQLLoader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我必须从文本文件中获取批量数据,并且需要使用SQLLoader插入Oracle表中.我需要在VB.Net解决方案中添加什么才能在Windows应用程序中执行SQL加载程序?

我已经使用System.Diagnostic命名空间编写了代码,以连接oracle数据源并使用System.Diagnistic.Process插入数据.但是没有插入记录.请给我您的意见.

我使用过的代码

Hi All,

I have to get bulk data from text file and need to insert into Oracle table using SQLLoader. What do I need to add to my VB.Net solution to be able to execute SQL loader within my windows application?

I have written code using System.Diagnostic namespace to connect oracle data source and insert data using System.Diagnistic.Process. But records were not inserted. Please give me your inputs.

Code which I have used

Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process
Dim myCommand As String = "CMD.EXE"
proc.StartInfo = New ProcessStartInfo(myCommand)
'Set up arguments for CMD.EXE
'bytReturn = WshShell.Run("sqlldr " & strUser & "/" & strDatabasePassword & "@pwb_stg parfile=../parm/all.par errors=0", normal, wait)
proc.StartInfo.Arguments = "sqlldr PWBIMP@PWB_DEV/2010_MUU_ImpTest CONTROL=uhc_excl_ctl.txt"
proc.StartInfo.RedirectStandardInput = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
proc.StartInfo.UseShellExecute = False
proc.StartInfo.WorkingDirectory = "P:\CPD\CESP\parm"

Try
proc.Start()
proc.WaitForExit(2000)
If (proc.ExitCode = 0) Then
'MsgBox.Show("Successfully Inserted")
MsgBox("Successfully Inserted")
Else
MsgBox(proc.StandardError.ReadToEnd)
End If
Catch ex As Exception
MsgBox(ex.Message)



我创建的控制文件(uhc_excl_ctl.txt)



Control File Which I created (uhc_excl_ctl.txt)

LOAD DATA
INFILE uhc_excluded_ftin_list.txt
BADFILE uhc_excluded_ftin_list_log.txt
INTO table Test1
FIELDS TERMINATED BY  ","
(ProductName,ProductGroupName)



谢谢
Ramesh



Thanks
Ramesh

推荐答案

嗨..,

为什么要调用cmd.exe ..,而无需调用cmd.exe,则可以直接调用sqlldr.exe来加载数据.
这里正在更改您的代码..,未经测试.您必须在PC中进行调试.

Hi..,

why are invoking the cmd.exe.., no need to invoke the cmd.exe, you can directly invoke the sqlldr.exe to load data..

here am changing your code .., this is not tested. you have to debug in your pc .

Dim proc As System.Diagnostics.Process = New System.Diagnostics.ProcessDim myCommand As String = "sqlldr.EXE"
proc.StartInfo = New ProcessStartInfo(myCommand)'Set up arguments for CMD.EXE'bytReturn = WshShell.Run("sqlldr " & strUser & "/" & strDatabasePassword & "@pwb_stg parfile=../parm/all.par errors=0", normal, wait)proc.StartInfo.Arguments = "PWBIMP@PWB_DEV/2010_MUU_ImpTest CONTROL=uhc_excl_ctl.txt"
proc.StartInfo.RedirectStandardInput = Falseproc.StartInfo.RedirectStandardOutput = Trueproc.StartInfo.RedirectStandardError = Trueproc.StartInfo.UseShellExecute = Falseproc.StartInfo.WorkingDirectory = "P:\CPD\CESP\parm"
Tryproc.Start()proc.WaitForExit(2000)If (proc.ExitCode = 0) Then'MsgBox.Show("Successfully Inserted")MsgBox("Successfully Inserted")ElseMsgBox(proc.StandardError.ReadToEnd)End IfCatch ex As ExceptionMsgBox(ex.Message)



试试吧.



try it.,


Rajesh,

感谢您的答复.

我用sqlldr.exe替换了cmd.exe.但是应用程序说:系统找不到指定的文件"

Hi Rajesh,

Thanks for the reply.

I replaced cmd.exe with sqlldr.exe. But application says, "the system cannot find specified file"

What do I need to add to my VB.Net solution to be able to execute SQL loader within my windows application?



谢谢,
拉梅什.



Thanks,
Ramesh.


这篇关于如何在Vb.Net中使用SQLLoader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆