Question
1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Question Submitted By :: Aseem
I also faced this Question!!
Rank
Answer Posted By
Re: 1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer
# 1
<%@ 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>
Deepak
Re: 1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer
# 2
1)We can't add connection string in global.asax file. we can
create connection string in web.config file only.
2)global.asax,web.config,Default.aspx files and
app_code,app_data,app_themes folders.
Himasankar
Re: 1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer
# 3
Connection String can be stored as an Application Variable.
Jerry Joseph
Re: 1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer
# 4
it is possible only by using session but it is not
good practics
Sandeep
Re: 1.can we add connection string in global.asax??????????
2.what are the default files included when we create new
web application????
Answer
# 5
no,we can't add the connection string in global.asax..
global.asax is a text file,It is use to define the global
variable.
Chaitali