1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer Posted / deepak
<%@ Import Namespace=”System.Data” %>
<%@ Import Namespace=”System.Data.Odbc” %> <script
language=”C#” runat=”server”>
void Application_Start()
{
//Connection string for SQL Server with trusted
connection
Application.Add (”DB_CONNECTION_STRING”,”DRIVER={SQL
Server};SERVER=ServerName;DATABASE=DataBaseName;Trusted_connection=yes;”);
}
void Session_Start()
{
//open connection to database
OdbcConnection cnConnection = new OdbcConnection
(Application.Get(”DB_CONNECTION_STRING”).ToString());
cnConnection.Open();
Session.Add (”DB_CONNECTION”, cnConnection );
}
void Session_End()
{
//a graceful disconnect
OdbcConnection cnConnection = (OdbcConnection)
Session["DB_CONNECTION"];
cnConnection.Close ();
}
</script>
| Is This Answer Correct ? | 11 Yes | 2 No |
Post New Answer View All Answers
What is in a session cookie?
How can we inherit a static member?
What are the steps to follow to host a web application on a web server?
What is the exact purpose of http handlers?
Explain the steps needed to be performed in order to create an animation in xaml?
If we remove web.config or machine.config from the application then, is this application will works?
What is difference between web config and global asax?
Out of ASP or ASP.NET which one is stateless?
Define repository pattern in mvc.net? : asp.net mvc
What is the purpose of master page?
What are server side controls?
What websites use asp.net?
Explain the Order of events in an asp.net page?
Where do we store our connection string in asp.net application?
How we can force all the validation controls to run?