D
Dlwxn
Unregistered / Unconfirmed
GUEST, unregistred user!
程序是服务的形式,在2000下没有任何问题,在2003双核的情况下才会出现。<br>出现的概率不大,每天大概一到两次,出现后服务就挂了。<br>为了调试,我写在每个语句上面都对ErrorCode进行了改变。<br>ErrorCode = 的值有时候是1、6、11,也就是说随机的。<br><br>Access violation at address 006C6974. Write of address 0112E530<br><br>下面的代码:代码逻辑比较简单,稍微看一下就能明白。<br><br>变量定义:<br>nmg_ADOConnection :TADOConnection<br><br>//是写日志的过程,可以不用管。<br>AddLogToFileEx<br>//NMC_SQLText_UpdateLineInfo 是常量,SQL语句。<br><br>{-------------------------------------------------------------------------------<br> 功能: 保存用户状态到数据库 <br> 过程名: TNEGMMangerState.SaveStateToDataBase<br> 作者: Steven<br> 日期: 2007.06.04<br> 参数:<br> AID: Integer; //用户ID<br> AState: Integer; //状态标准<br> AStateText: string; //状态名称<br> ALoginOut: Boolean //是否登出<br> 返回值: 无<br>-------------------------------------------------------------------------------}<br>procedure TNEGMMangerState.SaveStateToDataBase(AID: Integer;<br> AState: Integer; AStateText: string; ALoginOut: Boolean);<br>var<br> nmm_ADOQu: TADOQuery;<br> I, ErrorCode: string;<br>begin<br> I := '0';<br> ErrorCode := '0';<br> try<br> if Self.nmg_ADOConnection = nil then Exit;<br> ErrorCode := '1';<br> nmm_ADOQu := CreateAdoQueryEx(Self.nmg_ADOConnection);<br> ErrorCode := '2';<br> if nmm_ADOQu = nil then<br> begin<br> ErrorCode := '3';<br> Exit;<br> end;<br><br> with nmm_ADOQu do<br> begin<br> try<br> ErrorCode := '4';<br> if ALoginOut then<br> begin<br> ErrorCode := '5';<br> SQL.Add(NMC_SQLText_UpdateLineInfo);<br> end<br> else begin<br> ErrorCode := '6';<br> SQL.Add(NMC_SQLText_UpdateUserLine);<br> end;<br> ErrorCode := '7';<br> SQL.Add(NMC_SQLText_UpdateLineWhere);<br> ErrorCode := '8';<br> Parameters.ParamByName('ID').Value := AID;<br> ErrorCode := '9';<br> Parameters.ParamByName('E_Name').Value := '';<br> ErrorCode := '10';<br> Parameters.ParamByName('Negm_UserStatus').Value := AStateText;<br> ErrorCode := '11';<br> Parameters.ParamByName('Negm_IsonLine').Value := AState;<br> ErrorCode := '12';<br> if ALoginOut then<br> begin<br> ErrorCode := '13';<br> Parameters.ParamByName('DataObject').Value := 0;<br> end;<br><br> try<br> ErrorCode := '14';<br> ExecSQLCommand(Self.nmg_MutexHandle, nmm_ADOQu, ecs_Exec);<br> ErrorCode := '15';<br> except<br> on E:Exception do<br> begin<br> if nmm_ADOQu = nil then<br> AddLogToFileEx('nmm_Adoqu is null 11');<br> AddLogToFileEx(E.Message, 'NEGM_Svr_State->uMain.pas', 'SaveStateToDataBase 11');<br> end;<br> end;<br><br> finally<br> if not (nmm_ADOQu is TADOQuery) then<br> AddLogToFileEx('nmm_ADOQu is not valid');<br> if not (Self is TNEGMMangerState) then<br> AddLogToFileEx('Self is not valid');<br> if not (nmg_ADOConnection is TADOConnection) then<br> AddLogToFileEx('nmg_ADOConnection is not valid');<br> I := 'free';<br> FreeAndNil(nmm_ADOQu);<br> CoUninitialize;<br> end;<br> end;<br> except<br> on E: Exception do<br> begin<br> AddLogToFileEx('dword(@Self) :' + IntToStr(dword(@Self)));<br> AddLogToFileEx('(PDWORD(Self.nmg_ADOConnection))^ :' + IntToStr((PDWORD(Self.nmg_ADOConnection))^ );<br> AddLogToFileEx('dword(@Self.nmg_ADOConnection) :' + IntToStr(dword(@Self.nmg_ADOConnection)));<br><br> AddLogToFileEx('i = ' + i);<br> AddLogToFileEx('ErrorCode = ' + ErrorCode);<br><br> AddLogToFileEx('nmm_intTemp = ' + IntToStr(nmm_intTemp));<br> if (I <> 'free') and (nmm_ADOQu = nil) then<br> AddLogToFileEx('nmm_Adoqu is null');<br> AddLogToFileEx(E.Message, 'NEGM_Svr_State->uMain.pas', 'SaveStateToDataBase');<br> end;<br> end;<br>end;<br><br><br>function CreateAdoQueryEx(AADOConn: TADOConnection): TADOQuery;<br>begin<br> Result := nil;<br> if AADOConn = nil then<br> begin<br> Exit;<br> end;<br> CoInitialize(nil);<br> Result := TADOQuery.Create(nil);<br> try<br> Result.Connection := AADOConn;<br> Result.Close;<br> Result.SQL.Clear;<br> Result.Parameters.Clear;<br> except<br> on E: Exception do<br> begin<br> AddLogToFileEx(E.Message, 'uFunction.pas', 'CreateAdoQueryEx');<br> FreeAndNil(Result);<br> CoUninitialize;<br> end;<br> end;<br>end;<br><br><br><br><br>从属模块: D:/netmarch/NTService/Plugins/NEGM_Svr_State.dll<br>09:01:33 i = free<br><br>从属模块: D:/netmarch/NTService/Plugins/NEGM_Svr_State.dll<br>09:01:33 ErrorCode = 7<br><br>从属模块: D:/netmarch/NTService/Plugins/NEGM_Svr_State.dll<br>09:01:33 nmm_intTemp = 1000<br><br>从属模块: D:/netmarch/NTService/Plugins/NEGM_Svr_State.dll<br>09:01:33 单元名: NEGM_Svr_State->uMain.pas<br> 过程名: SaveStateToDataBase<br>////////////////////////////////////////////////<br><br>ErrorCode = 的值有时候是1、6、11,也就是说随机的。<br>nmm_intTemp 是Self的一个全局变量,在Self.Create的时候赋值为1000,为了判断出错的时候,Self对象是表示不存在了。