http://www.asp.net/web-api/overview/error-handling/exception-handling
-
Recent Posts
Archives
Categories
Meta
http://www.ebooks.in.th/download/13061/MetaStock_Made_Easy_-_RMO_Trade_Model
http://topicstock.pantip.com/sinthorn/topicstock/2012/03/I11821282/I11821282.html
META Stock database
http://inv5.asiaplus.co.th/cms/index2.php?sc=asp_res_present&tab=dm&ln=t
Version No. | Release Date | Visual Studio Version | Default in Windows | CLR Version | Features in Release |
---|---|---|---|---|---|
1.0 | 13 Feb 2002 | Visual Studio .NET | NA | 1.0 | First Version of CLR and Base Class Library |
1.1 | 24 Apr 2003 | Visual Studio 2003 | Windows Server 2003 | 1.1 | 1. First Major version of .NET Framework 2. Built-in support for mobile ASP.NET controls. Previously available as an add-on for .NET Framework, now part of the framework 3. Security changes – enable Windows Forms assemblies to execute in a semi-trusted manner from the Internet, and enable Code Access Security in ASP.NET applications 4. Built-in support for ODBC and Oracle databases. Previously available as an add-on for .NET Framework 1.0, now part of the framework 5. .NET Compact Framework – a version of the .NET Framework for small devices 6. Internet Protocol version 6 (IPv6) support |
2.0 | 7 Nov 2005 | Visual Studio 2005 | Windows Server 2003 R2 | 2.0 | 1. Generics 2. Language support for generics built directly into the .NET CLR 3. Full 64-bit support for both the x64 and the IA-64 hardware platforms 4. SQL Server integration – .NET 2.0, VS 2005, and SQL Server 2005 are all tied together. This means that instead of using T-SQL, one can build stored procedures and triggers in any of the .NET-compatible languages 5. A new hosting API for native applications wishing to host an instance of the .NET runtime. The new API gives a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more 6. Many additional and improved ASP.NET web controls 7. New data controls with declarative data binding 8. New personalization features for ASP.NET, such as support for themes, skins, master pages and webparts 9. .NET Micro Framework – a version of the .NET Framework related to the Smart Personal Objects Technology initiative 10. Membership provider 11. Partial classes 12. Nullable types 13. Anonymous methods 14. Iterators 15. Data tables |
3.0 | 6 Nov 2006 | Visual Studio 2005 | Windows Vista, Windows Server 2008 | 2.0 | 1. Windows Presentation Foundation (WPF), a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies 2. Windows Communication Foundation (WCF), a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services 3. Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows 4. Windows CardSpace, a software component which securely stores a person’s digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website |
3.5 | 19 Nov 2007 | Visual Studio 2008 | Windows 7, Windows Server 2008 R2 | 2.0, 2.0 SP1, 3.0 SP1 | 1. Added new features such as AJAX-enabled Web sites and LINQ 2. Source code of Base Class Library (BCL) has been partially released 3. New .NET Compact Framework 3.5 released |
3.5 SP1 | 11 Aug 2008 | Visual Studio 2008 | Windows 7, Windows Server 2008 R2 | 3.0 SP2 | 1. .NET Framework Client Profile 2. Dynamic Data 3. Two new data service components added, ADO.NET Entity Framework and ADO.NET Data Services 4. Two new assemblies for web development, System.Web.Abstraction and System.Web.Routing 5. New set of controls “Visual Basic Power Packs” introduced |
4.0 | 12 Apr 2010 | Visual Studio 2010 | NA | 4.0 | 1. New Version of CLR 2. Parallel Extensions to improve support for parallel computing, which target multi-core or distributed systems. To this end, technologies like PLINQ (Parallel LINQ), a parallel implementation of the LINQ engine, and Task Parallel Library, which exposes parallel constructs via method calls are included 3. New Visual Basic .NET and C# language features, such as implicit line continuations, dynamic dispatch, named parameters, and optional parameters 4. Code Contracts 5. Inclusion of new types to work with arbitrary-precision arithmetic (System.Numerics.BigInteger) and complex numbers (System.Numerics.Complex) 6. Dynamic Language Runtime (DLR) 7. Managed Extensibility Framework (MEF) 8. Windows Server AppFabric for application server capabilities in the form of AppFabric hosting and in-memory distributed caching support |
4.5 | 15 Aug 2012 | Visual Studio 2012 | Windows 8, Windows Server 2012 | 4.5 | 1. Windows Store Apps 2. The Portable Class Library project in Visual Studio 2012 3. Background Garbage Collection Servers 4. Asynchronous File Operations 5. Regex Timeout 6. Profile Optimization – Improved Startup Performance 7. Zip Compression 8. Async and Await – Code Markers |
Credit : Jinal Desai .NET
เก็บไว้เตือนตัวเองเวลาเจอ Error ที่เกิดจาก Dataset
Exception Message “Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.”
Root Cause : คือ มีฟิลด์ที่ Max Length น้อยกว่าค่าที่มีใน Field นั้นๆ (แต่มันดันเสือกบอกเกียวกับ constraints กูหาไป หลายวันเลย)
วิธีตรวจสอบ
DirectCast(dt.Rows(0),DataRow).RowError “This directly gives the error”
ฉนั้นเวลาใ้ช้ Dataset ต้องจำไปไว้ว่าต้อง management exception ตัวนี้ออก log มาด้วย เวลาตรวจสอบจะได้ไม่ลำบากแบบนี้
Try
Dim dt as new Datatabl
…….
…….
…….
catch ex as excepton
write log > DirectCast(dt.Rows(XXXXX),DataRow).RowError
end
byte[] file = File.ReadAllBytes("some path\\test.pdf"); MemoryStream ms = new MemoryStream(file) Response.Buffer = True Response.ClearContent() Response.ClearHeaders() Response.AddHeader("Cache-Control", "max-age=3") Response.AddHeader("Pragma", "public") Response.ContentType = "application/pdf" Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf") Response.AddHeader("Content-Length", ms.Length.ToString) Response.BinaryWrite(ms.ToArray()) Response.Flush() Response.End()
Establishing a connection with a database server is a hefty and high resource consuming process. If any application needs to fire any query against any database server, we need to first establish a connection with the server and then execute the query against that database server.
Not sure whether you felt like this or not; when you are writing any stored proc or a query, the query returns the results with better response time than the response time, when you execute that same query from any of your client applications. I believe, one of the reasons for such behavior is the overheads involved in getting the desired results from the database server to the client application; and one of such overheads is establishing the connectionbetween the ADO.
Web applications frequently establish the database connection and close them as soon as they are done. Also notice how most of us write the database driven client applications. Usually, we have a configuration file specific to our application and keep the static information like Connection String in it. That in turn means that most of the time we want to connect to the same database server, same database, and with the same user name and password, for every small and big data.
ADO.NET with IIS uses a technique called connection pooling, which is very helpful in applications with such designs. What it does is, on first request to database, it serves the database call. Once it is done and when the client application requests for closing the connection, ADO.NET does not destroy the complete connection, rather it creates a connection pool and puts the released connection object in the pool and holds the reference to it. And next time when the request to execute any query/stored proc comes up, it bypasses the hefty process of establishing the connection and just picks up the connection from the connection pool and uses that for this database call. This way, it can return the results comparatively faster.
Let us see Connection Pooling Creation Mechanism in more detail.
Connection pool and connection string go hand in hand. Every connection pool is associated with a distinctconnection string and that too, it is specific to the application. In turn, what it means is – a separate connectionpool is maintained for every distinct process, app domain and connection string.
When any database request is made through ADO.NET, ADO.NET searches for the pool associated with the exact match for the connection string, in the same app domain and process. If such a pool is not found, ADO.NETcreates a new one for it, however, if it is found, it tries to fetch the usable connection from that pool. If no usable free connection is found in the pool, a new connection is created and added to the pool. This way, newconnections keep on adding to the pool till Max Pool Size is reached, after that when ADO.NET gets request for further connections, it waits for Connection Timeout time and then errors out.
Now the next question that arises is – How is any connection released to the pool to be available for such occasions? Once any connection has served and is closed/disposed, the connection goes to the connection pooland becomes usable. At times, connections are not closed/disposed explicitly, these connections do not go to thepool immediately. We can explicitly close the connection by using Close()
or Dispose()
methods of connectionobject or by using the using
statement in C# to instantiate the connection object. It is highly recommended that we close or dispose (don’t wait for GC or connection pooler to do it for you) the connection once it has served the purpose.
Connection pool is removed as soon as the associated app domain is unloaded. Once the app domain is unloaded, all the connections from the connection pool become invalid and are thus removed. Say for example, if you have an ASP.NET application, the connection pool gets created as soon as you hit the database for the very first time, and the connection pool is destroyed as soon as we do iisreset
. We’ll see it later with example. Note thatconnection pooling has to do with IIS Web Server and not with the Dev Environment, so do not expect theconnection pool to be cleared automatically by closing your Visual Studio .NET dev environment.
ADO.NET 2.0 introduces two new methods to clear the pool: ClearAllPools
and ClearPool
. ClearAllPools
clears the connection pools for a given provider, and ClearPool
clears the connection pool that is associated with a specific connection. If there are connections in use at the time of the call, they are marked appropriately. When they are closed, they are discarded instead of being returned to the pool.
Refer to the section “Simple Ways to View Connections in the Pool Created by ADO.NET” for details on how to determine the status of the pool.
Connection string plays a vital role in connection pooling. The handshake between ADO.NET and database server happens on the basis of this connection string only. Below is the table with important Connection pooling specific keywords of the connection strings with their description.
Name | Default | Description |
ConnectionLifetime | 0 | When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified byConnection Lifetime. A value of zero (0) causes pooledconnections to have the maximum connection timeout. |
ConnectionTimeout | 15 | Maximum Time (in secs) to wait for a free connection from the pool |
Enlist | ‘true’ | When true , the pooler automatically enlists the connection in the creation thread’s current transaction context. Recognized values aretrue , false , yes , and no . Set Enlist = "false" to ensure thatconnection is not context specific. |
Max PoolSize | 100 | The maximum number of connections allowed in the pool. |
Min PoolSize | 0 | The minimum number of connections allowed in the pool. |
Pooling | ‘true’ | When true , the SQLConnection object is drawn from the appropriate pool, or if it is required, is created and added to the appropriate pool. Recognized values are true , false , yes , and no . |
Incr PoolSize | 5 | Controls the number of connections that are established when all theconnections are used. |
Decr PoolSize | 1 | Controls the number of connections that are closed when an excessive amount of established connections are unused. |
* Some table contents are extracted from Microsoft MSDN Library for reference.
Other than the above mentioned keywords, one important thing to note here. If you are using Integrated Security, then the connection pool is created for each user accessing the client system, whereas, when you use user id and password in the connection string, single connection pool is maintained across for the application. In the later case, each user can use the connections of the pool created and then released to the pool by other users. Thus using user id and password are recommended for better end user performance experience.
The connection string with the pooling related keywords would look somewhat like this
initial catalog=Northwind; Data Source=localhost; Connection Timeout=30; User Id=MYUSER; Password=PASSWORD; Min Pool Size=20; Max Pool Size=200; Incr Pool Size=10; Decr Pool Size=5;
We can keep a watch on the connections in the pool by determining the active connections in the database after closing the client application. This is database specific stuff, so to see the active connections in the database server we must have to use database specific queries. This is with the exception that connection pool is perfectly valid and none of the connections in the pool is corrupted.
For Microsoft SQL Server: Open the Query Analyser and execute the query : EXEC SP_WHO
.
For Oracle : Open SQL Plus or any other editor like PL/SQL Developer or TOAD and execute the following query —SELECT * FROM V$SESSION WHERE PROGRAM IS NOT NULL
.
All right, let us do it with SQL Server 2000:
EXEC SP_WHO
query. Note the loginname
column, and look for MACHINENAME\ASPNET. If you have not run any other ASP.NET application, you will get no rows withloginname
as MACHINENAME\ASPNET."initial catalog=Northwind; Min Pool Size=20;Max Pool Size=500; data source=localhost; Connection Timeout=30; Integrated security=sspi"
.iisreset
on the Run
Command."Max Pool Size = N;"
in the connection string, where N
is the new Max Pool size.Off
. Well, this indeed is not a good idea as connection pooling puts a positive performance effect, but it definitely is better than getting any such exceptions."Validate Connection=true"
in the connection string. Well, in couple of places, I noticed people saying use "validcon=true"
works for them for prior versions on ODP.NET. See which works for you. With ODP.NET v 9.2.0.4, "validcon=true"
errors out and "Validate Connection=true"
works just fine.static
(shared in Visual Basic .NET) method SqlConnection.ClearPool
or clear all of theconnection pools in an appdomain by using the SqlConnection.ClearPools
method. Both SqlClient and OracleClient implement this functionality.Close
/Dispose
the connections once its usage is over.In a nutshell, connection pooling can increase the performance of any application by using active connections of the pool for consecutive requests, rather than creating a new connection each time. By default, ADO.NET enables and uses connection pooling due to its positive impact. And at the same time, the developer who is the best judge of his/her application, can configure the connection pooling features, or can even switch it off, based on the applications need by simply using power keywords of connection string.
Please spare some time to rate and provide feedback about this article. Your couple of minutes can help in enhancing the quality of this article.
Credit
http://www.codeproject.com/Articles/17768/ADO-NET-Connection-Pooling-at-a-Glance
– ขนมปังขอบเนี้อ ที่บ่อมีปั่นขายอยู่แล้ว แต่อย่าให้เก่ามากมันจะมีกลิ่นเปรี้ยวมาก เป็นเปลือกล้วนปั่นก็ได้ครับที่บ่อมีเช่นกัน ให้เขาปั่นให้ได้เลย
– สำหรับคนที่ตกที่เงาน้ำ มีเหยื่อนวด รำข้าวคั่ว ก็ใช้ได้นะครับ เติมกระทิ แล้วใส่หัวเชื้อสูตรแดง ตีลูกโดด รำข้าวคั่วก็ตะกร้อ หรือผสมอีกอย่าง NKA หัวเชื้อสูตรเขียว
– ขนมปังขอบผสมน้ำไว้แล้วให้หมาดๆนะครับ หรือบางคนจะชอบนิ่ม แต่จะเหวี่ยงเหยื่อยากหน่อย แล้วแต่ชอบ
ปกติผสมน้ำแล้วทิ้งไว้ประมาณ 10 นาที ขนมปังก็จะเริ่มนุ่ม ก็โรยหัวเชื้อลงไป โรยไปทีละชั้นประมาณว่ากำได้ 4-5 ลูก
– ใช้ควักนะครับ อย่ากวน
– ตะกร้อที่ใช้ โดยปกติจะใช้ทั้งแบบใส่โฟม และ ใส่ตะกั่วทรงโอ่งตัดครึ่งใช้แค่ครึ่งเดียวแล้วใส่ในแกนตะกร้อ หรือจะใช้ตะกร้อเปล่าๆก็ได้
– ไลน์สตอปเปอร์ ประมาณ 5-6 นิ้ว
– สายหน้าตัวเบ็ดเกี่ยวเหยื่อ ผมผูกกัน 3-4 นิ้ว ปลากินยากๆ ก็อาจจะผูกยาวขึ้น
– ตัวเบ็ดผมใช้กันเบอร์ 9 10 เสียส่วนมาก เพราะใช้คันอ่อนหน่อย
– แต่ถ้าปลาบึกเข้ากินดีก็เบอร์ 11 12 ปลาบึกจะใช้เบ็ดใหญ่หน่อยได้
– ระยะเหวี่ยงเหยื่อออกไปประมาณ 40% ของความกว้างของบ่อ แต่บางครั้งปลากินยากๆ ก็ไกลออกไปประมาณ 60 ถึง 70%
– ตกทุ่นลอย วางไลน์ความลึกไม่เกิน 50-60 ซม.
– ติ่งขนมปังชิ้นประมาณปลายนิ้วก้อย
Encapsulation เป็น implementation ของ concept ที่ว่า “don’t tell me how you do it; just do it” คือการกำหนด interface ของ object ทั้ง method และ data ให้ object อื่นๆมองเห็นเท่าที่จำเป็นเท่านั้น ซึ่งก็คือการกำหนด public protected private ให้สำหรับ method และ data ของตัว object นั่นเอง
ส่วน Data hiding เป็นคุณลักษณะของ OOP คือตัว object จะมีความเกี่ยวข้องกับ data ที่ถูกกำหนดไว้ใน class เท่านั้น ซึ่งก็หมายถึงการซ่อน data ต่างๆไว้ภายใน object นั่นเอง
นั่นคือ Encapsulation ก็มีคุณสมบัติของ Data hiding ด้วยนั่นเอง เพราะมีการกำหนด private ให้ data เพื่อซ่อน data ไว้ภายใน object
Thk. Bomber (http://www.narisa.com/forums/index.php?showtopic=4969)
Information hiding คือ “หลักการ” ซ่อนข้อมูลไม่ให้ภายนอกเห็น เพื่อลดความซับซ้อนของโมดูล ไม่ว่าโมดูลนั้นจะเป็น function หรือ object
Encapsulation คือ “วิธีการ” ในการซ่อนข้อมูลโดยการรวบรวม element ต่างๆเป็น entity อันใหม่
Information hiding ซ่อนข้อมูล ส่วน Encapsulation สร้าง entity ใหม่จากข้อมูลหลายๆตัวที่ถูกซ่อนและเกี่ยวข้องกัน
Thk. นายข้าวโพดหวาน (http://www.narisa.com/forums/index.php?showtopic=4969)