|
|
Hi
I have problem retriving data form Oracle DB.
I get "Object reference is not set to an instance of an object" error on line after //****
public override void Load(int id)
{
try
{
EROS2.Library.cDataHandle dh = new EROS2.Library.cDataHandle();
dh.Add("I_PK_CAMERA_ID", id.ToString(), EROS2.Library.ValueDataType.vInteger, EROS2.Library.DiretcionType.vInput, 0);
//****
DataTable dataTable = GetDataTableFromPackage("PKG_DCMS_CAMERA.PR_GET_CAMERA", dh);
if (dataTable != null && dataTable.Rows.Count == 1)
{
DataRow dr = dataTable.Rows[0];
LoadFromDS(dr);
}
}
catch (Exception ex)
{
TCSCore.TCSWindowsEventLog.LogException(ex);
}
}
here is rest of code involved:
public DataTable GetDataTableFromPackage(string packagename, EROS2.Library.cDataHandle parameters)
{
parameters.Add("o_cursor", "", EROS2.Library.ValueDataType.vCursor, EROS2.Library.DirectionType.vOutput, 0);
parameters.Add("o_return", "", EROS2.Library.ValueDataType.vInteger, EROS2.Library.DirectionType.vOutput, 0);
return m_Database.OracleConnection.GetDataTable(packagename, parameters);
}
and the store procedure:
----------------------------------------------------------------------------
procedure PR_GET_CAMERA(I_PK_CAMERA_ID in CAMERA.PK_CAMERA_ID%type, O_CURSOR OUT CursorType, O_RETURN OUT NUMBER) AS
err_num number;
err_msg varchar2(255);
proc_name CONSTANT VARCHAR(255) := 'PR_GET_CAMERA';
BEGIN
o_return := 1;
OPEN O_CURSOR FOR
SELECT CAMERA.*, CAMERA_STATUS.DESCRIPTION as CAMERA_STATUS, ADDEVICE.ADD_DESCRIPTION as ADD_DESCRIPTION,
ADDEVICE.PK_ADD_ID as PK_ADD_ID, ADDEVICE.ADD_CAM_TYPE as IS_MOBILE_TYPE
FROM CAMERA
JOIN ADDEVICE
ON ADDEVICE.PK_ADD_ID = CAMERA.FK_ADD_ID
JOIN CAMERA_STATUS
ON CAMERA.FK_CAMERA_STATUS_ID = CAMERA_STATUS.PK_CAMERA_STATUS_ID WHERE PK_CAMERA_ID = I_PK_CAMERA_ID;
o_return := 0;
EXCEPTION WHEN OTHERS THEN
o_return:= SQLCODE;
err_num := SQLCODE;
err_msg := 'SQLCODE: ' || SQLCODE || CHR(10) || err_msg || ':' ;
pr_store_error('Err', err_msg, err_num, proc_name);
END PR_GET_CAMERA;
----------------------------------------------------------------------------
I've checked and the id is passed properly to Load(), name of store proceduere is correct and the code works fine with different store procedures (id is different and name of procedure differs). SQL query similar to store procedure returns row without problem.
Whats wrong with it then?
|
|
|
|
|
Hi. I want to create a dialog which shows the progress of a file copy operation. I'll be copying a batch of files, some of which are up to 40Mb, so I want to display the current file progress aswell as the total progress. The problem I'm having is when I invoke the method for updating the UI. Because I want to update each for file I'm having to cycle through the source file byte by byte and then invoke the method which is using up all my memory. This is what I have so far. Any help would be appreciated.
FileCopyDialog.zip[^]
|
|
|
|
|
Maby its just me but what are you doing?
I see these totaly useless loops, why dont you just use File.ReadAllBytes and then write it out to file again and if you must have a byte by byte view. You can easily loop trough the byte array and write it out one by one.
And your why dont you just use the worker report progress function?
Well i hope this helps and maby i just dont get the picture.
|
|
|
|
|
Cheers for the reply. As I said, I need to display the current transfer progress for each file aswell as the total progress for all files so I need to write byte by byte (which it is doing) and then update the UI's progress bar with the current progress after each byte has been written. I'm not sure which loops you see as unnecessary btw as all 3 of them have a purpose. As for the workers' ProgressChanged event, it only has one value for percent complete and I need two.
modified on Wednesday, July 2, 2008 8:23 AM
|
|
|
|
|
First off, ignore the ReadAllBytes suggestion, if your files are 40MB and you do have a few of them then its going to suck up alot of memory.
If you copy the file like this, you will be able to keep track of where you are:
const int BUFFERSIZE = 32768;
int bytesRead = 0;
long totalBytesRead = 0;
long fileSize = 0;
FileStream input = new FileStream("myfile", FileMode.Open);
FileStream output = new FileStream("mydestination", FileMode.Create);
byte[] buffer = new byte[BUFFERSIZE];
fileSize = input.Length;
.
while(totalBytesRead < fileSize)
{
bytesRead = input.Read(buffer, 0, BUFFERSIZE);
output.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}
Don't copy the file one byte at a time either, it will just go really slow. You can see your progress by checking totalBytesRead against fileSize .
Infact, you could set up an event and fire it in the while loop. Your main thread could then use this to update your progress bar etc.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Legend! Marriage proposal is in the post
|
|
|
|
|
I'm not sure I'd would do this the same way, totalBytesRead would have to be class variable and volatile to display it on the UI. Else the worker has a copy of the original data and can't change it.
Why not use a delegate you could invoke to update the UI from the worker?
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
I did say you could set up an event and trigger that during the loop, you would pass a copy of totalBytesRead and fileSize through that to the main thread.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
This is an example of what I've done, just in case anybody else needs something similar in the future. Cheers for your help guys.
FileCopyTest.zip[^]
|
|
|
|
|
Hi All,
I am encountered a problem when I build my project , all Time "Compilation Error" appear !!!
what is the problem?
how can i solve that's problem ?
Ala Qunaibi
modified on Wednesday, July 2, 2008 7:28 AM
|
|
|
|
|
ALAQUNAIBI wrote: what is the problem?
Your code is broken.
ALAQUNAIBI wrote: how can i solve that's problem ?
Fix the code.
|
|
|
|
|
Fantastic, sometimes the solution can be so simple!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
leppie wrote: ALAQUNAIBI wrote:
what is the problem?
Your code is broken.
ALAQUNAIBI wrote:
how can i solve that's problem ?
Fix the code.
That's real experience speaking there. Damn, you and your years of coping with subtle problems like this.
|
|
|
|
|
1st read the error message, it will contain clues as to what you have done wrong.
2nd, Google for the error message, other people may have asked about it before so you might find clues.
3rd, when and only when you have done both of the above, if you are still stuck, post the full error message displayed, and the line of code that it says causes the error and we'll try to help.
Simon
|
|
|
|
|
I have a treeview control whose particular node needs to be dynamically selected during page load. Kindly let me know the way to do this.
|
|
|
|
|
TreeView treeView = new TreeView();
treeView.Nodes.Add("Monday");
treeView.Nodes.Add("Tuesday");
treeView.SelectedNode = treeView.Nodes[1];
Something like that anyway This would select the "Tuesday" node.
|
|
|
|
|
No this does not work. Thanks anyways.
The scenario is something like this.
1. On one page I have a tree view.
2. I select a node and add the node vale in a session variable.
3. On another page I have the treeview.
4. Here I fetch the session variable i.e. the selected node value.
Now I have to use this variable to automatically select the same node.
|
|
|
|
|
For some business reasons, i need my win form app run with fullscreen and not allow user to click any hot keys (such as windows button, alt+tab ,etc.) to go back to desktop or close the program.
is it possible to do this?
thank
^^
|
|
|
|
|
i read somewhere that we have three ways of showing forms/dialogs (i did not remember exact text)
1- normal form.Show()
2- modal form.ShowDialog()
3-system modal ?
i don't know how to have system modal but it said that it will work for your purpose
I Wish the Life Had CTRL-Z
Wizard's First Rule : People are fool,they believe what they want to believe or what they afraid to believe
www.subaitech.blogspot.com
|
|
|
|
|
No, it's not.
The user has, and always should have final control of their PC. There is no way to intercept the Ctrl+alt+del button press. Only the WinLogon process can receive notification of this key combo.
What is your reason for wanting to do this?
Simon
|
|
|
|
|
bug_aonz wrote: For some business reasons...
Yeah, right. Am I the only one who smells malware?
|
|
|
|
|
not neccecaraly...
i wanted to do the same thing last year trying to port the examination system we used at my collage to C#... if your writing an exam you dont want students googling the questions... so thats a perfectly legit reason to want this...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Don't have browsers on the computers.
Don't attach the computers to the Internet.
Detect the attempt and fail the student.
Mightn't they still be able to use a Web-enabled phone?
|
|
|
|
|
The propose is to prevent shop attendant not to use any thing except only my program which is developed for product ordering.
|
|
|
|