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,

CodePudding user response:

reference 4 floor ying1234 response:
can consider the SqlConnection object set to the static, to bad, after you online
so haven't learned to ajax, and no way to get multiple button first, so this is suitable for use in learning practice

CodePudding user response:

reference 5 floor they blame me reply:
Quote: refer to 4th floor ying1234 response:
can consider the SqlConnection object set to the static, to bad, after you online
so haven't learned to ajax, and no way to get multiple button first, so this is suitable for use in learning phase practice


Wrong, the first step you should walk the right path, tamper with, finally out of the question have to turn head,
To search a SqlHelper are better than you this kind of practice

CodePudding user response:

Why want to manually shut down,,, link the database connection string plus one using is not ok,,,,
  • Related