Asp. NET development Web site program Common error Summary

Source: Internet
Author: User
Tags end sql net return string oracle database

In using Visiol Studio.NET to develop Web applications, developers often encounter some problems: such as I developed a good program, in the development environment test is no problem, how to move to the application environment, there will be problems? Not the program's inability to run, is the program's efficiency slow with the snail in the crawl, this situation in. NET's new hands are particularly common. I don't know why, some introductions. NET development of the book cited in the example code, but also to ignore this problem, especially let me depressed is some of my favorite books, such as: <<ado. NET Technology Insider >>,<<asp. NET2.0 Advanced Programming (4th Edition) >> both are published by Tsinghua University Press, and there is a book worse <<visual Basic.NET professional project development >> I suggest that we should not look at it, avoid wasting time and energy.

This article is not only for. NET Developer's Novice has the help, similarly to which has the experience, also brings some enlightenment and the reference.

What kind of problems they will encounter, I may summarize to you:

1. Database connection Timeout

2. Create objects to use, regardless of release

3. Debug (Debug) mode is compiled and used in the application environment.

4. Sharing the actual mode of operation

The problem above is like a cancer that accumulates to a certain extent and has far-reaching consequences.

One, the database connection timeout article

To know the database connection timeout problem, first look at the following code:

[SAMPLE-01]:
Public Shared Function GETOEMPN (ByVal pspn As String, ByRef Oempn as String) as Bsresult
0001 Dim Clsresult as New bsresult
0002 Try
0003 Clsresult.resultid =-1
0004 Dim Dtresult as New DataTable
0005 Dim Sql as String = String.Empty
0006 Dim clsoradb as New clsoracliendb
0007 Dim strconn as String = Configurationmanager.connectionstrings ("ConnectionString"). ConnectionString
0008 Clsoradb.open (strconn) ' Here Open, behind see Clsoradb.close
0009 Sql = "Select Satbmmbrnd. OEMPN Fruno from Satbmmbrnd WHERE satbmmbrnd. Matno =: Matno "
0010 Dim params () as OracleParameter = {New OracleParameter ("Matno", PSPN)}
0011 If clsoradb.filldatatable (SQL, dtresult, params) = False Then
0012 return Clsresult
0013 End If
0014 If Dtresult is nothing Then
0015 return Clsresult
0016 End If
0017 If dtResult.Rows.Count > 0 Then
0018 OEMPN = dtresult.rows (0) ("Fruno"). ToString ()
0019 Else
0020 OEMPN = ""
0021 End If
0022 Clsresult.resultid = 1
0023 return Clsresult
0024 Catch ex as Exception
0025 Clsresult.resultid =-1
0026 return Clsresult
0027 End Try
End Function

A partial explanation of the above line of code:


0006: A class referencing a database connection;
0008: Open the database connection;

Then, the entire function you can not find the action to close the database connection, is to wait for the operating system to release it? Someone said, it doesn't seem like a big deal, it's just a function; The database opens the connection, does not close does not affect the entire application; Is that true?

Let's talk about database connectivity, in the Oracle database, the general default number of database connections is up to 100 Torai, not more than 200, even if you change the number of connections, but no matter how the number of connections is limited, it is not unlimited for you to consume.

In the Web this program, it not only does not automatically shut down the database connection, like such a function will be called every time, will reuse a database connection; If there are a lot of functions like this, you will be waiting for an error warning page to bounce out, such as database Connection Timeout ... and other information.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.