473,624 Members | 2,252 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_equipment s

SET ( DRIVER_FIRST_NA ME,

DRIVER_LAST_NAM E,

ACTUAL_MILES_QT Y,

DRIVER_CUID,

AUDIT_LAST_USER _ID,

AUDIT_LAST_UPD_ DT)

VALUES (?,?,?,?,?,SYSD ATE)

WHERE flt_equip_id = ? ";

res = OleDbHelper.Exe cuteNonQuery(sq lQuery,

CommandType.Tex t,

OleDbHelper.Cre ateParam("@pFir st_name",OleDbT ype.VarChar,
20,"pFirst_name ",info.FirstNam e),

OleDbHelper.Cre ateParam("@pLas tName",OleDbTyp e.VarChar,
20,"pLastName", info.LastName),

OleDbHelper.Cre ateParam("@pCur rentOdo",OleDbT ype.Integer,
7,"pCurrentOdo" ,info.CurrentOd ometerReading),

OleDbHelper.Cre ateParam("@pDri verCUID",OleDbT ype.VarChar,
8,"pDriverCUID" ,info.DriverCui d),

OleDbHelper.Cre ateParam("@pCUI D",OleDbType.Va rChar,
30,"pCUID",Sess ion["CUID"]),

OleDbHelper.Cre ateParam("@pUni tNumber",OleDbT ype.VarChar,
8,"pUnitNumber" ,info.UnitNumbe r));
if(res > 0)

return true;

else

return false;

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

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

HttpContext.Cur rent.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**********@q west.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
5260
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 user have to open a form and entera date so we know in report that the desiered check has been cleared. It takes me while to wrtie. But when I try to update the datagrid changes via dataset to MS Access 2003 I get an error that simply says...
3
1623
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 store all the values entered until the last page and then update the database, or should I do it as I go.
4
1827
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 creating an adapter and then copy, paste, modify it's code to suite my needs. This was the end result: Private sub updateTable( ) Dim myData As DataSet 'Command is a form level oledbcommand object Dim Adapter1 As New OleDbDataAdapter(Command)
29
2113
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 a database i.e. I've modified the table in a DataSet and I want to update it to the SQL database which the table originally came from. I'm using a data adaptor and the update command and it works BUT it is soooooooooo slow!!! Can anybody tell me...
10
1632
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) and Visual Basic .NET created an update command--very long as there are a lot of fields. Now there are more large tables to copy. Is there an easy way to have Visual Basic create these update commands itself for the other tables with out...
1
1508
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. final String udc = "UPDATE INTO " + "Comm_WebSubmission Set ProjectID = request.getParameter("ProjectID") (Assigned,DateAssigned,Status,StatusDescription,Resolution,CompletionDate) values(?,?,?,?,?,?)";
6
5202
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 table adaptor. I would like to update the b ase tables thorugh the view. How do i do this? FYI: I have some reserarch on how to handle updating multiple tables and making sure I don't break referential integrity, yet in this case I will not be...
2
1742
by: nannu | last post by:
m using this code :........................... ======================================================================= OleDbConnection con =new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\ic411242\My Documents\db2.mdb"); con.Open (); OleDbDataAdapter adp =new OleDbDataAdapter();
3
4792
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 narrowed the problem down to the department_id parameter which is set from a hidden field. I can confirm this by hard coding the UpdateCommand to: UPDATE configuration SET special_notes=@special_notes WHERE (student_id=@student_id) AND...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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 we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.