Local loCommand As 'ADODB.Command',loConnection As 'ADODB.Connection'
loCommand = Createobject('ADODB.Command')
SQLCreateParameter(loCommand, 'X')
SQLCreateParameter(loCommand, 'USA')
loCommand.CommandText = "Update Customers set region = ?+region where Country = ?"
loConnection = Createobject('ADODB.Connection')
loConnection.ConnectionString = 'Provider=SQLNCLI;server=.\sqlexpress;Trusted_connection=yes;Database=Northwind'
loConnection.Open
loCommand.ActiveConnection = loConnection
lnAffected = 0
loCommand.Execute(@lnAffected)
loConnection.Close
? m.lnAffected
Procedure SQLCreateParameter
Lparameters toCommand As ADODB.Command, tuParameter, tcName
tcName = Evl(m.tcName, Textmerge('P<<toCommand.Parameters.Count+1>>'))
Local loParm As 'ADODB.Parameter'
loParm = toCommand.CreateParameter(m.tcName)
loParm.Direction=1
Do Case
Case Type('m.tuParameter') = 'C'
If Len(m.tuParameter) > 4000
loParm.Type = 201 && adLongVarChar
loParm.Size = -1
Else
loParm.Type = 200 && adVarChar
loParm.Size = Max(1,Len(Nvl(m.tuParameter,'')))
Endif
Case Type('m.tuParameter') = 'D'
loParm.Type = 133 && adDBDate
Case Type('m.tuParameter') = 'T'
loParm.Type = 135 && adDBTimeStamp
Case Type('m.tuParameter') = 'Y'
loParm.Type = 6 && adCurrency
Case Type('m.tuParameter') = 'N'
loParm.Type= 3 && adNumeric
Case Type('m.tuParameter') = 'Q'
loParm.Type = 205 && adLongVarBinary
loParm.Size = -1
Case Type('m.tuParameter') = 'L'
loParm.Type = 11 && adBoolean
Endcase
If loParm.Type = 205 && adLongVarBinary
loParm.Value = Createbinary(m.tuParameter)
Else
loParm.Value = m.tuParameter
Endif
toCommand.Parameters.Append( loParm )
Endproc