N
nate axtell
In VB .NET 1.1 I have created an oledbcommand object that queries the
xp_cmdshell in the Master database. This part works fine. But when I try
to access the Return_Value parameter's value there is nothing there.
IsNothing() returns True; IsDBNull() returns False. Shouldn't the
xp_cmdshell procedure return an integer value? Here's my code:
Dim conn as New OleDbConnection(connstr)
Dim cmd as New OleDbCommand("xp_cmdshell", conn)
cmd.CommandTimeout = 300 '** 6 min timeout
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("", OleDbType.VarChar, 4000).Value = valid_osql_string
Try
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Catch ex as Exception
'** show error
End Try
cmd.Parameters.Add("RETURN_VALUE", OleDbType.Integer).Direction =
ParameterDirection.ReturnValue
IsDbNull(cmd.Parameters("RETURN_VALUE").Value) '** returns False
IsNothing(cmd.Parameters("RETURN_VALUE").Value) '** returns True
I tried adding the parameter before the cmd.ExecuteNonQuery call but
received the following error:
"Error executing extended stored procedure: Invalid Parameter Type."
xp_cmdshell in the Master database. This part works fine. But when I try
to access the Return_Value parameter's value there is nothing there.
IsNothing() returns True; IsDBNull() returns False. Shouldn't the
xp_cmdshell procedure return an integer value? Here's my code:
Dim conn as New OleDbConnection(connstr)
Dim cmd as New OleDbCommand("xp_cmdshell", conn)
cmd.CommandTimeout = 300 '** 6 min timeout
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("", OleDbType.VarChar, 4000).Value = valid_osql_string
Try
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Catch ex as Exception
'** show error
End Try
cmd.Parameters.Add("RETURN_VALUE", OleDbType.Integer).Direction =
ParameterDirection.ReturnValue
IsDbNull(cmd.Parameters("RETURN_VALUE").Value) '** returns False
IsNothing(cmd.Parameters("RETURN_VALUE").Value) '** returns True
I tried adding the parameter before the cmd.ExecuteNonQuery call but
received the following error:
"Error executing extended stored procedure: Invalid Parameter Type."