减少C#中.ldf的大小 [英] Decrease size of the .ldf in C#

查看:86
本文介绍了减少C#中.ldf的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



如何在c#中减小.ldf文件(ldf登录sql 2008)的大小。没有脚本,如何在c#中编写代码。



感谢所有

Dear all,

How to decrease size of the .ldf file (ldf log in sql 2008) in c#. No script, how to make to code in c#.

Thanks for all

推荐答案

如果我理解你的问题然后通过C#代码减小LDF文件的大小是不可行的。



原因:LDF文件是由数据库实例生成的。此事务日志文件的格式由SQL Server实例维护。这就像,你可以通过C#代码减少PDF文件,Doc文件的大小,而不需要任何供应商组件。



是的,你肯定可以编写一个连接到的程序数据库实例,可以执行以下操作。



If I understand your question then decreasing size of LDF file through C# code is not doable.

Reason: LDF file is getting generated by database instance. This transaction logs file's format is getting maintain by SQL server instance. This is like, can you reduce size of PDF file, Doc file through just C# code without any vendor component.

Yes for sure you can write a program which connects to database instance and can perform below actions.

SQLDatabase.TransactionLog.Truncate();
SQLDatabase.Shrink(5, SQLDMO.SQLDMO_SHRINK_TYPE.SQLDMOShrink_NoTruncate);
SQLDatabase.TransactionLog.Truncate();
SQLDatabase.Shrink(5, SQLDMO.SQLDMO_SHRINK_TYPE.SQLDMOShrink_Default);







如果您要减小文件大小以归档它,那么只需编写一个程序到Zip(压缩)它,它将工作并且也将很容易。



- 谢谢Rushi




If you are decreasing file size to archiving it then simply write a program to Zip (Compress) it, it will work and will be easy also.

-- Thanks Rushi


您好Rushi并感谢您的解决方案,但是当放入此代码时,请输入错误:

{ 只有使用早期版本的SQL Server 2008才能访问此方法或属性。} System.Exception {Microsoft.SqlServer.Management.Smo.UnsupportedVersionException}
Hi Rushi and thanks for your solution, but when put this code, make the error:
{"This method or property is only accessible to work with an earlier version a SQL Server 2008."} System.Exception {Microsoft.SqlServer.Management.Smo.UnsupportedVersionException}


这篇关于减少C#中.ldf的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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