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 a form tag?
Does google crawl redirects?
What is routing in MVC?
Is post back property in asp net?
Why do we need master page in asp.net?
Explain authorization levels in .net ?
Explain how can we access static variable?
in which protocol ASP.NET WEB API Work?
What kind of data can be stored in viewstate?
what is publisher?
To load your generated dataset with data which method do you invoke?
Are cookies client side or server side?
What is class and object in asp.net?
How do u declare static variable and how it is declared and what is its lifetime?
What is the difference between Classic ASP and ASP.Net?