'VB.Net 2005 code example with question to follow:
The above code is an excerpt from a routine that I use to update a Sequal Server database record.
The question I'm asking is, do I need to set the oParm object = nothing each time or not? I'm confused about what this does/does not do.
I read where it is not necessary to set objects to nothing and I also read where sometimes you do. I also have warning messages in the wizard generated code (converted from VB6 to VB.Net) that warns me about setting objects to "nothing".
The warning alerts me to the fact that the object may still "live" for awhile after being set to nothing. If true (I've no doubt that it's true), then I would think the above routine has a problem. Having said that, I must reveal that this routine works.
VB.NET:
'Updates Sequal Server 2005 database
'
'Populate Parms
'
oParm = oData.Parameter("ExternalFile") 'Returns new Parm object
With oParm
.Size = bBytes.Length - 1
.DbType = DbType.Binary
.SqlDbType = SqlDbType.Image
.Value = CompressByteArray(bBytes)
End With
ocolParms.Add(oParm, oParm.ParameterName)
oParm = Nothing
'
oParm = oData.Parameter("ContentLength") 'Returns new Parm object
With oParm
.SqlDbType = SqlDbType.Int
.DbType = DbType.Int64
.SqlDbType = SqlDbType.Int
.Value = bBytes.Length - 1
End With
ocolParms.Add(oParm, oParm.ParameterName)
oParm = Nothing
'
oParm = oData.Parameter("ContentType") 'Returns new Parm object
With oParm
.Size = 50
.DbType = DbType.String
.SqlDbType = SqlDbType.VarChar
.Value = "image/pjpeg"
End With
ocolParms.Add(oParm, oParm.ParameterName)
oParm = Nothing
'
'Run SQL
'
oData.Execute(strSQL, ocolParms, , , 150, True)
ClearCollection(ocolParms)
The above code is an excerpt from a routine that I use to update a Sequal Server database record.
The question I'm asking is, do I need to set the oParm object = nothing each time or not? I'm confused about what this does/does not do.
I read where it is not necessary to set objects to nothing and I also read where sometimes you do. I also have warning messages in the wizard generated code (converted from VB6 to VB.Net) that warns me about setting objects to "nothing".
The warning alerts me to the fact that the object may still "live" for awhile after being set to nothing. If true (I've no doubt that it's true), then I would think the above routine has a problem. Having said that, I must reveal that this routine works.