you know it is a bad idea to keep a connection object in Application variable,right? considert multiple users are visiting your pages and accessing the database at the same time!just check if the object is still valid:if application("conn") is nothing then
  Response.Write("something is wrong")
else
  Resonse.Wrire(application("conn").GetType().Name)
end ifor
sqlAda=new sqldataAdapter(sqlstr,CType(application("conn"), SqlConnection))

解决方案 »

  1.   

    >>>我这样使用sqlconnection对象有问题吗?是不是效率会提高,请高手提点意见yes, it is wrong to do sotry to open a connection as late as possible, and close it as soon as possible and use connection pooling
      

  2.   

    我也发现这样用connection确实有很大的问题
    我想知道,你是如何更有效的使用connection的
    connection pooling 如何建立呢?
      

  3.   

    if you use the default, you get connection pooling, try to create connection objects as needed, then call its Close or Dispose method promptly
    see
    ADO.NET Connection Pooling FAQ
    http://www.c-sharpcorner.com/Code/2004/May/PoolingNS.aspADO.NET Connection Pooling Explained
    http://www.ondotnet.com/pub/a/dotnet/2004/02/09/connpool.html