locked
Data Access Application Block errors RRS feed

  • Question

  • User-82855278 posted
    I am experiencing a strange set of errors when using the application block In inspecting the code below, method 1 works while method 2 fails, with connection errors, but in method 1, I am still using the access blocks internal properties and methods to optain the connection, etc. I dont understand why the other method fails, any ideas Thanks davehole <%@ Page Language="vb" AutoEventWireup="False" %> <script runat="server"> Private Sub Page_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim Database As Microsoft.Practices.EnterpriseLibrary.Data.Database = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()'("Ski Australia Sql") Dim CommandWrapper As Microsoft.Practices.EnterpriseLibrary.Data.DBCommandWrapper = Database.GetSqlStringCommandWrapper("SELECT TOP 1 ProductName FROM [SkiAustralia].[Products];") 'Method 1 - Works Perfectly CommandWrapper.Command.Connection = Database.GetConnection() CommandWrapper.Command.Connection.Open() Response.Write(CommandWrapper.Command.ExecuteScalar().ToString()) CommandWrapper.Command.Connection.Close() CommandWrapper.Command.Connection.Dispose() 'Method 2 - Fails Response.Write(Database.ExecuteScalar(CommandWrapper).ToString()) End Sub </script>
    Wednesday, March 16, 2005 4:32 AM

All replies

  • User613648415 posted
    Pls remove these two.. CommandWrapper.Command.Connection.Close() CommandWrapper.Command.Connection.Dispose() Try now.. -Lingaraj
    Monday, March 21, 2005 11:34 AM