简体   繁体   English

SqlDataAdapter和数据库的事务日志已满

[英]SqlDataAdapter and The transaction log for database is full

I'm trying to update/insert huge number of data into a database 我正在尝试将大量数据更新/插入数据库

I'm using the following code: 我正在使用以下代码:

using (SqlCommand command = connection.CreateCommand())
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = storedProcedureName;
                command.UpdatedRowSource = UpdateRowSource.None;

                foreach (SqlParameter sqlParameter in sqlParameters)
                    command.Parameters.Add(sqlParameter);


                var adapter = new SqlDataAdapter();
                adapter.InsertCommand = command;
                adapter.UpdateBatchSize = batchSize;

                return adapter.Update(table);
            }

and i'm using the following stored procedure: 我正在使用以下存储过程:

    @shareAdGroupId int,
@groupPermissionName varchar(100)

AS
BEGIN transaction
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.@permissionTypeName

    declare @permissionId int
    EXEC  [dbo].[PROC_UPSERT_PERMISSION] @permissionName = @groupPermissionName,  @permissionId = @permissionId OUTPUT


    SET NOCOUNT ON;
        BEGIN TRY
        begin
            INSERT INTO [dbo].SHARE_AD_GROUP_PERMISSION
           (SHARE_AD_GROUP_ID,PERMISSION_ID)
        VALUES
           (@shareAdGroupId,@permissionId)
        end
    END TRY
    BEGIN CATCH
        --RETURN ERROR_MESSAGE() 
    END CATCH
commit transaction

After inserting/updating a random number of record, i get the error: 插入/更新随机数的记录后,我得到错误:

System.Data.SqlClient.SqlException: The transaction log for database 'dbName' is full. System.Data.SqlClient.SqlException:数据库'dbName'的事务日志已满。 To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases 要找出无法重用日志中的空间的原因,请参阅sys.databases中的log_reuse_wait_desc列。

I know this question has been asked many time, however I searched to find out if the way I'm updating/inserting is causing the issue. 我知道很多时候都会问过这个问题,但是我搜索了一下我是否更新/插入的方式导致问题。

Since I'm not a DBA and I have no rights on the db server, I cannot modify the backup logs, however I don't really care if the issue is only that. 由于我不是DBA而且我对数据库服务器没有任何权限,因此我无法修改备份日志,但是如果只是问题,我并不在意。 Then this is up to the dba to solve it. 那么这取决于dba来解决它。

My question is, in the coding part, am I doing something wrong, can I improve that somehow? 我的问题是,在编码部分,我做错了什么,我能以某种方式改进吗?

Thanks 谢谢

no, this error is only fixable on the DBA end, so there isn't anything you can really do without rights. 不,这个错误只能在DBA端修复,所以如果没有权限,没有任何东西可以做到。 either the volume that the disk is on is running out of space, the log file has hit its quota, or the auto-growth for the log file is not set correctly. 要么磁盘所在的卷空间不足,日志文件已达到其配额,要么未正确设置日志文件的自动增长。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM