Home > Net > The asp.net database operations, will object reference not set to an instance of an object
The asp.net database operations, will object reference not set to an instance of an object
Time:09-26
Today, I wrote a page to set up a global SqlConnection object, setting up a button (bt1) connect to the database, and another button (bt2) close the database, Then at runtime, click the first button, then point the second button, display "will object reference not set to an instance of an object", because the click on the button will refresh the page, the object needs to be initialized, so point button after the object is null, When you haven't learned to Ajax, you can consider the SqlConnection object set to the static, or the need to reuse parts of the set to the static, thus, also need not run to set OnClientClick properties of the space, because it may make your prompt box play not to come out
CodePudding user response:
Want to open a blog can take notes
CodePudding user response:
CodePudding user response:
Half serious look at the problem of
CodePudding user response:
Consider the SqlConnection object set to the static, to bad after you online,