如何在C#.net中检索sql日志文件 [英] How to retrieve sql log file in C# .net

查看:68
本文介绍了如何在C#.net中检索sql日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我了解到使用SPOOL Command可以实现oralce SQL命令的日志记录,如果我通过SQL Plus或Toad执行oracle sql脚本,它工作正常,而相同的逻辑当我尝试通过C#执行sql脚本时无法正常工作。



我需要的是,在网页上点击按钮应该执行一组应针对上述操作创建针对Oracle DB的DML语句和日志文件。



请告知从C#执行sql并生成相同的日志文件。



试用代码:

-----------



后台打印'D:/MyFolder/MyLogFile.txt';



从双选择sysdate;



假脱机;



谢谢,

Priya

Hi,
I learnt that logging for an oralce SQL commands can be achieved using SPOOL Command, it is working fine if I execute the oracle sql scripts via SQL Plus or Toad, whereas the same logic is not working when i try to execute the sql script via C#.

On a high level my need is, a button click in a web page should execute a set of DML statements against Oracle DB and the log file should be created for the above action.

Please advise in executing the sql from C# and generating the log file for the same.

Trial Code:
-----------

Spool 'D:/MyFolder/MyLogFile.txt';

select sysdate from dual;

Spool off;

Thanks,
Priya

推荐答案

您无需启动SQLPlus来执行某些SQL工作。您可以使用ODP.NET连接到Oracle数据库并执行SQL脚本。
You don't need to start SQLPlus to do some SQL work. You may use ODP.NET to connect to Oracle Database and execute your SQL script.


这篇关于如何在C#.net中检索sql日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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