RoyHobbs99223
Posts: 37
|
Posted: 11/29/2010, 5:28 PM |
|
I am trying to add custom session variables to the Button/Server/OnClick Event, right after the login event. Did this before with ASP no problem, but trying to move up to .NET C# and not getting anywhere. CCS help = not helpful.
Below is what worked in ASP, I could just use this code to create a custom session variable called 'alxerp' and populate it with field data from a query.
Now, I need to do this in ASP.NET C#. Can you help me convert what is below into custom code for ASP.NET C#?
Dim Connection1
Set Connection1 = New clsDBT31SQL
Connection1.Open
Session("alxerp") = CCDLookUp("alxerp","vTEK_0715","alx="& Connection1.ToSQL(CCGetUserID(),ccsInteger), Connection1)
Connection1.Execute("UPDATE PPL_Users SET LastLogin=getdate() WHERE alxcontact="&CCGetUserID)
Connection1.Close
Set Connection1 = Nothing
Anything you can advise would be appreciated. Thanks!
|
|
|
dragoon
Posts: 173
|
Posted: 11/30/2010, 12:31 AM |
|
HttpContext.Current.Session["var1"] = blahblah
HttpContext.Current.Session["var2"] = ...
|
|
|
RoyHobbs99223
Posts: 37
|
Posted: 11/30/2010, 7:58 AM |
|
Ah, yes. Thank you. Couple follow up questions:
With regard to the blahblah part, , what would be the correct syntax for looking up a value in the DB where UserID is the one now in the session?
What is the command for executing a SQL update like in line 6 of the ASP code?
Thanks much.
|
|
|
dragoon
Posts: 173
|
Posted: 12/01/2010, 2:26 PM |
|
string Sql;
DataAccessObject NewDao = Settings.Connection1DataAccessObject;
Sql = "UPDATE PPL_Users SET LastLogin=getdate() WHERE alxcontact=" + NewDao.ToSql(CCGetUserID().ToString(),FieldType.Text);
NewDao.RunSql(Sql);
just have a look on how CCS is building update methods...
Update: Connection1 is the name of the connection string; rename as you have it in your own project.
|
|
|
|