{"id":801,"date":"2014-08-20T11:59:00","date_gmt":"2014-08-20T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/08\/20\/powertip-mini-scripting-games-2014-answer-3\/"},"modified":"2014-08-20T11:59:00","modified_gmt":"2014-08-20T11:59:00","slug":"powertip-mini-scripting-games-2014-answer-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-mini-scripting-games-2014-answer-3\/","title":{"rendered":"PowerTip: Mini-Scripting Games 2014 Answer 3"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Here is the answer to the third question in Mini-Scripting Games&nbsp;2014.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;You are writing a script, and when it runs, you receive an error message that states: <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&ldquo;You cannot call a method on a null-valued expression.&quot; <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;What is the first thing you should check?<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Check the code that creates the object that you stored in the variable. It is probable that there is a <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; problem with that code. For example, let&#039;s say I read from a database and store the results from <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; that database to a variable, and then I call the&nbsp;<b>MoveNext()<\/b><i>&nbsp;<\/i>method.<\/p>\n<p style=\"margin-left:60px\">&nbsp; &nbsp;If I get an error message that tells me I cannot call a method on a null-valued expression, it means that <br \/>&nbsp; &nbsp;I did not successfully connect to the database or I did not return a record set from the database.<\/p>\n<p style=\"margin-left:60px\">&nbsp; &nbsp;This could be due to an invalid query or a query that returned no rows from the database.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Here is the answer to the third question in Mini-Scripting Games&nbsp;2014. &nbsp;You are writing a script, and when it runs, you receive an error message that states: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&ldquo;You cannot call a method on a null-valued expression.&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;What is the first thing you [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Here is the answer to the third question in Mini-Scripting Games&nbsp;2014. &nbsp;You are writing a script, and when it runs, you receive an error message that states: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&ldquo;You cannot call a method on a null-valued expression.&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;What is the first thing you [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=801"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}