Pages

Monday, September 13, 2010

Using web.config in Asp.net

Web.config file is the configuration  file for the Asp .net web application. An Asp .net application has minimum configuration file which keeps the configurations required for the corresponding application. Web.config file is written in XML with specific tags having meanings.

Web.config file is stored in Database connections, Session States, Error Handling, Security.

web.config of the Online Mobile Store
<configuration>
    <appSettings>
<add key="MM_CONNECTION_HANDLER_con" value="sqlserver.htm" />
       
        <add key="MM_CONNECTION_DATABASETYPE_con" value="SQLServer" />
        <add key="MM_CONNECTION_SCHEMA_con" value="" />
        <add key="MM_CONNECTION_CATALOG_con" value="" />
    </appSettings>
</configuration>

Now, comes a configuration file of Asp.net

config.aspx

//The runat="server" attribute indicates that the script should be processed on the server
<script runat="server">
sub dbcon
//Change the datasource, username and password    
Bcon = New sqlConnection("data source=micron;uid=sa;pwd=admin;initial catalog=gsmlanka")
cartCon= New sqlConnection("data source=micron;uid=sa;pwd=admin;initial catalog=gsmlanka")
end sub
public BCon As sqlConnection
public cartCon as sqlconnection
public BCmd As sqlCommand
public Mcmd as sqlcommand
public Tcmd as sqlcommand
public pcmd as sqlcommand

public objreader as SqlDataReader
public dr as sqldatareader
public cdr as sqldatareader
public tempdr as sqldatareader
Public intStart As Integer
PUBLIC INSERTSQL AS string
public updatesql as string
</script>