469,572 Members | 1,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Update Command Coding

I have the following for an update function and I want to be able to pass in
a session variable where it is within the update statement. Does anyone
know how you can pass this session variable in here? As it is currently, it
says that it does not exist in the class or namspace. I have been able to
use it on other pages this way, but does not seem to be working here.

public static bool SaveMileageInfo(FleetMileage info)

{

int res = 0;

string sqlQuery = @"UPDATE fleet_equipments

SET ( DRIVER_FIRST_NAME,

DRIVER_LAST_NAME,

ACTUAL_MILES_QTY,

DRIVER_CUID,

AUDIT_LAST_USER_ID,

AUDIT_LAST_UPD_DT)

VALUES (?,?,?,?,?,SYSDATE)

WHERE flt_equip_id = ? ";

res = OleDbHelper.ExecuteNonQuery(sqlQuery,

CommandType.Text,

OleDbHelper.CreateParam("@pFirst_name",OleDbType.V arChar,
20,"pFirst_name",info.FirstName),

OleDbHelper.CreateParam("@pLastName",OleDbType.Var Char,
20,"pLastName",info.LastName),

OleDbHelper.CreateParam("@pCurrentOdo",OleDbType.I nteger,
7,"pCurrentOdo",info.CurrentOdometerReading),

OleDbHelper.CreateParam("@pDriverCUID",OleDbType.V arChar,
8,"pDriverCUID",info.DriverCuid),

OleDbHelper.CreateParam("@pCUID",OleDbType.VarChar ,
30,"pCUID",Session["CUID"]),

OleDbHelper.CreateParam("@pUnitNumber",OleDbType.V arChar,
8,"pUnitNumber",info.UnitNumber));
if(res > 0)

return true;

else

return false;

}
Nov 16 '05 #1
1 1424
Hi Brian:

You can use the Current property of the the HttpContext class to get
to the session, i.e.

HttpContext.Current.Session

HttpContext is in the System.Web namespace, so you'll need to add a
using clause if not present. Some additional information here:
http://odetocode.com/Articles/112.aspx

Another approach to seriously consider is to pass what you need as a
parameter to the method, or add CUID as a memeber of the FleetInfo
class (if it makes sense from a OOP design point of view). The reason
being is that SaveMileageInfo then would not have to have any
dependancy on HttpContext, which is only going to be around if you are
processing a web request. Otherwise SaveMileageInfo seems like a nice
method you could use in any type of project.

--
Scott
On Wed, 30 Jun 2004 13:39:53 -0600, "Brian Conway"
<Br**********@qwest.com> wrote:
I have the following for an update function and I want to be able to pass in
a session variable where it is within the update statement. Does anyone
know how you can pass this session variable in here? As it is currently, it
says that it does not exist in the class or namspace. I have been able to
use it on other pages this way, but does not seem to be working here.


Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by William | last post: by
29 posts views Thread by Geoff Jones | last post: by
1 post views Thread by Cat | last post: by
6 posts views Thread by Greg P | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.