Hi Kumar,
If you have more than one region for development(DEV,UAT,PROD) its a good practise to store connection string in web.config.
Which will be easier for you to read the connection string and establish the connection in code behind file.
In Web.config file find connnectionstring section and replace with below code
<connectionStrings>
<add name="localConnectionString" connectionString="SERVER=.\SQL2008;DataBase=StudentDatabase;UID=rk.prabakar;pwd=*****;" providerName="System.Data.SqlClient"/>
<add name="serverConnectionString" connectionString="Server=server\SQL2008;Database=StudentServerDatabase;User ID=sa;Password=*******;providerName="System.Data.SqlClient"/>
</connectionStrings>
In server side code,
con = new SqlConnection(ConfigurationManager.ConnectionStrings["localConnectionString"].ToString());
or
con = new SqlConnection(ConfigurationManager.ConnectionStrings["serverConnectionString"].ToString());
Once you finalized with database, you can establish the connection like con.open();
And you start executing your command.
So connecting to server database is solely depends on the connection string.
Regards,
RK