473,499 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1491
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5242
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
3
1614
by: Simon | last post by:
Hi everyone, I have a small problem regarding a wizard that I'm making on my website. The wizard is obviously a series of pages that take values from the user. My question is: - Should I...
4
1819
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by...
29
2089
by: Geoff Jones | last post by:
Hi All I hope you'll forgive me for posting this here (I've also posted to ado site but with no response so far) as I'm urgently after a solution. Can anybody help me? I'm updating a table on...
10
1617
by: cj | last post by:
I have lots of tables to copy from one server to another. The new tables have been created to match the old ones. I practiced with one table. I created the select command (select * from tableA)...
1
1499
by: Cat | last post by:
I'm trying to create a online update form to a SQL table. I've never done this function before, and I'm not quite sure I have the coding correct. Below is the coding for the Update statement. ...
6
5196
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
2
1740
by: nannu | last post by:
m using this code :........................... ======================================================================= OleDbConnection con =new OleDbConnection...
3
4774
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.