normally when I create a website I use the connection string in classic ASP and I use the following
<%
Sub RemainingHols
if Session("UserID") = "" then
response.Redirect("LoginPage.asp")
else
' Initialise the db connection
Set objDBConn = Server.CreateObject("ADODB.Connection")
Set objDBCommand = Server.CreateObject("ADODB.Command")
objDBConn.Open Application("Conn")
objDBCommand.ActiveConnection = objDBConn
objDBCommand.CommandText = "spHolidaysRemaining"
objDBCommand.CommandType = adCmdStoredProc
' Set the parameters
objDBCommand.Parameters.Append objDBCommand.CreateParameter("@EmployeeID", adInteger)
objDBCommand("@EmployeeID") = session("UserID")
'Initialise the Recordset
Set objDBRS = Server.CreateObject("ADODB.RecordSet")
'Execute
objDBRS.open objDBCommand,,adOpenForwardOnly
Session("HollidayAllowance") = (objDBRS(0))
Session("BookedHolidays") = (objDBRS(1)).value
Session("TotalHolidays") = (objDBRS(2)).value
Session("Date") = (objDBRS(3))
Session("Time") = (objDBRS(4))
'Close and Destroy Objects - Start*******************************************************
Set objDBCommand=nothing
objDBConn.Close
Set objDBConn=nothing
'Close and Destroy Objects - End*********************************************************
end if
end sub
%>
I store the actually connection string in a global.asa page and the above in a functions page.
And I would call the sub on the page I want to functionality to perform on.
I have started to develop a website in ASP.net C# for practice and I was wondering how to do this in C#