sql server 2008 - How to find sql error code in vbscript adodb.command.execute for "create login" -


i'm trying find error code when attempting create login using adodb.command object.

if "create login" succeeds, adorecord object created. if fails, no ado object if created.

i display , log sql server error of failure. err object empty on failed execution.

the code:

tsqlcmd.commandtext = "create login " & uname & " password = '" & upw & "'" tsqlcmd.activeconnection = conn  on error resume next set adorec = tsqlcmd.execute() ' how find sql error ?  if err <> 0   serr.number = err.number   serr.description = err.description   serr.source = err.source   serr.helpcontext = err.helpcontext   createlogin = false    errmsg = "createlogin: adodb create command error: " & hex(serr.number) & vbcrlf & _           "desc: " & serr.description & vbcrlf & _           serr.source & vbcrlf   'fake logging   msgbox(errmsg)   exit function end if 

executecomplete event

the executecomplete event called after command has finished executing.

syntax executecomplete recordsaffected, perror, adstatus, pcommand, precordset, pconnection

parameters recordsaffected long value indicating number of records affected command.

perror error object. describes error occurred if value of

adstatus adstatuserrorsoccurred; otherwise not set.

adstatus eventstatusenum status value. when event called, parameter set adstatusok if operation caused event successful, or adstatuserrorsoccurred if operation failed. before event returns, set parameter adstatusunwantedevent prevent subsequent notifications.

pcommand command object executed. contains command object when calling connection.execute or recordset.open without explicitly creating command, in cases command object created internally ado.

precordset recordset object result of executed command. recordset may empty. should never destroy recordset object within event handler. doing result in access violation when ado tries access object no longer exists.

pconnection connection object. connection on operation executed.

remarks

an executecomplete event may occur due connection.execute, command.execute, recordset.open, recordset.requery, or recordset.nextrecordset methods.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -