I am using the sqlcommand often to execute queries on the SQL Server from my vb.net program. The problem I am having is that I have to keep retyping my commands. See below. Rather then redimming my commmands everytime is there a way to reuse them for ex. I want to reuse the cmd rather than renaming it to cmdprior. Also same applies to the irowsaffected variable.
Dim cmd As SqlCommand = New SqlCommand
Dim irowsaffected As Integer
cmd.CommandTimeout = "60"
cmd.CommandType = CommandType.Text
cmd.CommandText = "select count(*) from jcpmst1"
cmd.Connection = sqlupdate
irowsaffected = cmd.ExecuteScalar
cmd = Nothing
Dim cmdprior As SqlCommand = New SqlCommand
Dim irowsaffected3 As Integer
cmdprior.CommandTimeout = "90"
cmdprior.CommandText = "Delete from prior"
cmdprior.CommandType = CommandType.Text
cmdprior.Connection = sqlupdate
irowsaffected3 = cmdprior.ExecuteNonQuery
cmdprior = Nothing
irowsaffected3 = Nothing