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 are sessions used for?
Explain about Multi-Language integration?
What are early binding and late binding.
What are the Types of chaching. How to implement caching
Can master pages be nested?
Can we use html in asp.net?
What are resource file and how do we generate resource file?
What are session state modes in asp.net?
Explain the function of new view engine in asp.net? : asp.net mvc
A Web Service Can Only Be Written In .net. Is it True??
Can you explain one critical mapping? Performance issue which one is better? Whether connected lookup tranformation or unconnected one?
Explain the difference between overriding and overloading?
How do you secure your connection string information?
Define msil.
What are the various types of cookies in asp.net?