Click here to Skip to main content
15,909,039 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionMS Chart - Problem to display the records in Range Column Chart Pin
Jegansinna23-Jun-09 0:05
Jegansinna23-Jun-09 0:05 
QuestionError Pin
Flavia A22-Jun-09 23:36
Flavia A22-Jun-09 23:36 
AnswerRe: Error Pin
Christian Graus22-Jun-09 23:58
protectorChristian Graus22-Jun-09 23:58 
AnswerRe: Error Pin
Abhijit Jana23-Jun-09 0:23
professionalAbhijit Jana23-Jun-09 0:23 
GeneralRe: Error Pin
Flavia A23-Jun-09 0:45
Flavia A23-Jun-09 0:45 
GeneralRe: Error Pin
himanshu256123-Jun-09 0:47
himanshu256123-Jun-09 0:47 
GeneralRe: Error Pin
Abhijit Jana23-Jun-09 0:49
professionalAbhijit Jana23-Jun-09 0:49 
QuestionRegarding Asp >net with Hibernate:web.Cofing error Pin
RAKESH gaur mkcl22-Jun-09 21:49
RAKESH gaur mkcl22-Jun-09 21:49 
Hello EveryBody.
I am new in Nhibernate with Asp .Net.


MyFolder Structer is
in D Drive :
D:\online\OES
in this some folder like
OES.DAO---it is a Class libabrary
OnlineExam---It Is website in Asp .Net
and My solution File OES.sln

Tecnology used is VS2005,Nhibernate,Asp .Net,AJAX
I develope A Arcitectuer in which two layer .
One is website layer and one is my Class libarary whic name is OES.DAO.
OES.DAO CONTAION ALL BUSINESS logic.


OES.DAO CLASS LIABARY CONTAION SOME FOLDER

ONE OF THEM IS
1.dblayer: it contaion one class
which code is


Code:
using System;
using System.Collections;
using System.Web;
using NHibernate;
using NHibernate.Cfg;
using Iesi.Collections;
using OES.DAO.businessobjects;
using OES.DAO.util;

namespace OES.DAO.dblayer
{
/// <summary>
/// This is the main class for accessing the database via the NHibernate O/R mappings.
/// The middle tier should use this class for DB access!
///
/// The usage of this class is along the lines of:
/// 1. Call BeginDBWork() and use the session it returns for DP operations
/// 2. Call EndDBWork() - commits the transaction frees resources etc.
///
/// The above methods are to be called by the application at start/end of
/// processing a request. Individual ASP.NET pages are expected to use
/// GetCurrentSession() to work on their data!
///
/// </summary>
public class DBFacade
{

private const string SessionHTTPContextKey = "itexampractice-context_session";
private const string TransactionHTTPContextKey = "itexampractice-context_transaction";

private static readonly ISessionFactory sessionFactory;

private static readonly bool runningInMonoOnUnix;
private static readonly bool runningInMSDOTNET;

/// <summary>
/// Initialization method for the DB facade. Gor now it is a dummy since the static
/// initializer does the work
/// </summary>
public static void Init()
{
// ...
}

static DBFacade()
{


sessionFactory = new Configuration().Configure().BuildSessionFactory();
Log.Info("DB Facade being initilaized, Platform: " + OSInfo.PlatformName);
runningInMSDOTNET = OSInfo.PlatformIsWindows;
runningInMonoOnUnix = OSInfo.PlatformIsASortOfUnix;

if (runningInMonoOnUnix)
{
// TODO: Maybe special init code .. if necessary
};
}

/// <summary>
/// Opens a new session for woring with the database. At the same time starts
/// a new transaction. The session and transaction are saved under the server's
/// HTTP context. The session object is returned for subsequent operations
/// </summary>
public static ISession BeginDBWork()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[SessionHTTPContextKey] as ISession;
ITransaction currentTransaction = context.Items[TransactionHTTPContextKey] as ITransaction;

if ((currentSession == null) && (currentTransaction == null))
{
currentSession = sessionFactory.OpenSession();
context.Items[SessionHTTPContextKey] = currentSession;

currentTransaction = currentSession.BeginTransaction();
context.Items[TransactionHTTPContextKey] = currentTransaction;
} else
{
// TODO: Close sesion and transaction

// No current session
throw new SystemException(
"It seems someone is trying to open an NHibernate session, although " +
"one is already open!");
}

return currentSession;
}

/// <summary>
/// Returns the previosly opened session. Throws exception if it is not open!
/// </summary>
public static ISession GetCurrentSession()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[SessionHTTPContextKey] as ISession;

if (currentSession == null)
{
// No current session
throw new SystemException(
"It seems someone is trying to get a NHibernate session, although " +
"one is NOT currently open!");
}

return currentSession;
}

/// <summary>
/// Starts a new transaction within the same session. May be used when we have
/// processing spanning several transactions.
/// For convenience returns the session.
/// </summary>
public static ISession StartNewTransaction()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[SessionHTTPContextKey] as ISession;
ITransaction currentTransaction = context.Items[TransactionHTTPContextKey] as ITransaction;

if ((currentSession == null) || (currentTransaction == null))
{
// No current session
throw new SystemException("Starting new transaction but no session exists!");
}

currentSession.Flush();
// TODO: This is a workaround for problems with Mono and ADO.NET
// transactions. The bug is expected to be fixed in Mono in early
// 2008!
try
{
currentTransaction.Commit();
} catch (Exception e)
{
if ((!(e is NullReferenceException)) || runningInMSDOTNET)
{
throw e;
} else // NullRef in Mono
{
Log.Warning("DBFacade: Ignoring NullReferenceException - " +
"Workround for a Mono bug (versions prior to 1.2.6) " +
"with ADO.NET transactions!");
}
}

// Start a new transaction here
currentTransaction = currentSession.BeginTransaction();
context.Items[TransactionHTTPContextKey] = currentTransaction;

return currentSession;
}

/// <summary>
/// Ends a previously opened session. Commits the current transactions and
/// closes the session.
/// </summary>
public static void EndDBWork()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[SessionHTTPContextKey] as ISession;
ITransaction currentTransaction = context.Items[TransactionHTTPContextKey] as ITransaction;

if ((currentSession == null) || (currentTransaction == null))
{
// No current session
throw new SystemException("Ending DB work but no session exists!");
}

try
{
currentSession.Flush();
// TODO: This is a workaround for problems with Mono and ADO.NET
// transactions. The bug is expected to be fixed in Mono in early
// 2008!
try
{
currentTransaction.Commit();
} catch (Exception e)
{
if ((!(e is NullReferenceException)) || runningInMSDOTNET)
{
throw e;
} else // NullRef in Mono
{
Log.Warning("DBFacade: Ignoring NullReferenceException - " +
"Workround for a Mono bug (versions prior to 1.2.6) " +
"with ADO.NET transactions!");
}
}
} finally
{
context.Items.Remove(SessionHTTPContextKey);
context.Items.Remove(TransactionHTTPContextKey);

// TODO: Close the session in any case - to start clean!
currentSession.Close();
};
}

/// <summary>
/// Releases all NHibernate resources for DB oprations. To be called at the
/// exit of the Web application.
/// </summary>
public static void CloseSessionFactory()
{
if (sessionFactory != null)
{
sessionFactory.Close();
}
}

}
}





Here I Got Error sessionFactory = new Configuration().Configure().BuildSessionFactory();


2.Thesecond FOLDER in OES.DAO IS businessobjects
WHICH CONTAION the all classes which map the database Tables.


Now In My Fisrt Layer whic name is OnlineExam [It is website] and My Solution File name is OES.

The Mapping hb.xml Files in dbmappings Folderls which map Database tables one of then is
AnswerToMCQuestion.hbm.xml


Code:
<?xml version="1.0" encoding="utf-8" ?>


<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace=" OES.DAO.businessobjects" assembly="OES.DAO" >
<class name="AnswerToMCQuestion" table="tAnswerToMCQuestion">
<id name="Id">
<column name="cId"/>
<generator class="uuid.hex" />
</id>
<property name="CreationDateTicks">
<column name="cCreationDateTicks"/>
</property>
<property name="IsRightAsInt">
<column name="cIsRight"/>
</property>
<property name="AnswerText">
<column name="cAnswerText"/>
</property>
<property name="NumInOrder">
<column name="cNumInOrder"/>
</property>
<many-to-one
name="Question"
class="MultipleChoiceExamQuestion"
column="cQuestionId"
not-null="true"/>

</class>
</hibernate-mapping>




Now The main Thing is Web.Config file setting where I got Error bz i dont know how to Map these .HBM.XML File here and how i give The Path bz My Business logic table which map the database tables in OES.DAO layesr .



Code:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>



<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory >
<!-- SECTION TO BE CHANGED DEPENDING ON DATABASE AND RUNTIME ENVIRONMENT -->
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Data Source=.;Initial Catalog=sd;User ID=sa;Password=sa;</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="show_sql">false</property>

[b]
<mapping resource="../config/common/dbmappings/User.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/QuestionComment.hbm.xml" assembly="OES"/>
<mapping resource="../config/common/dbmappings/QuestionRating.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/TestExamination.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/Exam.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/ExamSection.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/Vote.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/VoteByLink.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/ExamQuestion.hbm.xml" assembly="OES" />
<mapping resource="../config/common/dbmappings/AnswerToMCQuestion.hbm.xml" assembly="OES" />[/b]

</session-factory>

</hibernate-configuration>




<system.web>
<!--<trust level="Medium"/>-->
<httpRuntime executionTimeout="1000" maxRequestLength="250000"/>
<!--<sessionState mode="InProc" cookieless="false" timeout="180"/>-->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<globalization culture="en-us" uiCulture="en"/>
<compilation debug="true">
<assemblies>

<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
</compilation>
<!--<authentication mode="Forms">
<forms loginUrl="Login.aspx"/>
</authentication>-->
<authorization>
<allow users="*"/>
</authorization>
<customErrors mode="Off">
</customErrors>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
</system.web>
<!--<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>-->
</configuration>





In Mapping Tag i dont understand How I give The Path .
which Assempbly path I give .How I give the .HBM.XML File Path .

Please Help me All professionls .I am New In Nhibernate
I wam waiting For Replies.

Rakesh Gaur
mkclrakesh@gmail.com
QuestionSystem.Drawing.Image " Security Error" Pin
Robymon22-Jun-09 20:56
Robymon22-Jun-09 20:56 
AnswerRe: System.Drawing.Image " Security Error" Pin
Christian Graus22-Jun-09 23:59
protectorChristian Graus22-Jun-09 23:59 
GeneralRe: System.Drawing.Image " Security Error" Pin
Robymon23-Jun-09 0:12
Robymon23-Jun-09 0:12 
GeneralRe: System.Drawing.Image " Security Error" Pin
Christian Graus23-Jun-09 0:55
protectorChristian Graus23-Jun-09 0:55 
Question[Message Deleted] Pin
KhandelwalA22-Jun-09 20:46
KhandelwalA22-Jun-09 20:46 
AnswerRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 20:59
himanshu256122-Jun-09 20:59 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 21:04
KhandelwalA22-Jun-09 21:04 
GeneralRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 21:11
himanshu256122-Jun-09 21:11 
GeneralRe: error: The server tag is not well formed Pin
J4amieC22-Jun-09 23:08
J4amieC22-Jun-09 23:08 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 23:13
KhandelwalA22-Jun-09 23:13 
GeneralRe: error: The server tag is not well formed Pin
Christian Graus23-Jun-09 0:00
protectorChristian Graus23-Jun-09 0:00 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA23-Jun-09 0:06
KhandelwalA23-Jun-09 0:06 
AnswerRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 21:08
himanshu256122-Jun-09 21:08 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 21:17
KhandelwalA22-Jun-09 21:17 
GeneralRe: error: The server tag is not well formed Pin
K030622-Jun-09 21:35
K030622-Jun-09 21:35 
AnswerRe: error: The server tag is not well formed Pin
padmanabhan N22-Jun-09 21:22
padmanabhan N22-Jun-09 21:22 
Questionproblem in sending mail using gmail account Pin
prateekfgiet22-Jun-09 20:27
prateekfgiet22-Jun-09 20:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.