code_junkie

DbNull.Value Stored Procedure Parameter?

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Using dtResult as New DataTable
  2. Using cn as SqlConnection = New SqlConnection ("ConnectionString")
  3. Using sqlcmd as SqlCommand - New SqlCommand("StoredProceName", cn) with {.CommandType=CommandType.StoredProcedure}
  4.  
  5. Dim sp As SqlParameter
  6. sp = sqlcmd.Parameters.Add("@Count", SqlDbType.Int)
  7. sp.value = CType(Nothing, SqlTypes.SqlInt32)
  8.  
  9. Using myDR as SqlDataReader = sqlcmd.ExecuteReader
  10. dtResult.Load(myDR)
  11. end using
  12. return dtResult
  13. End Using ' For sqlcmd
  14. cn.Close() ' Close the connection
  15. end using ' For cn
  16. end using ' For dtResult
Add Comment
Please, Sign In to add comment