|
Can anyone tell me what is the meaning of this message when I try to update BLOB data into an ms access database file via OleDbCommand? the update of BLOB
field performs fine but I receive the following Error message:
"The program encountered an error trying to perform the command.if the problem persists, contact the program vendor for a possible solution."
My Code is as below :
public void UpdateOutLettDoc(byte[] DocImage,string LettId)
{
try
{
LoadTable("OutLetters");
if (Conn.State != ConnectionState.Open)
Conn.Open();
string upCmdString = "UPDATE OutLetters SET LettPage=@DocImage WHERE LettId=" + LettId;
OleDbCommand OleCmm = new OleDbCommand(upCmdString, Conn);
OleCmm.Parameters.Add("@LettPage", OleDbType.Binary, (int)DocImage.Length, "LettPage");
OleCmm.Parameters["@LettPage"].Value = DocImage;
OleCmm.ExecuteNonQuery();
if (Conn.State == ConnectionState.Open)
Conn.Close();
}
catch(OleDbException ex)
{
MessageBox.Show(ex.ToString());
}
}
As you see I used try{} block to catch exceptions but this Error is never detected by try{} block.
Please Help me!
-- modified at 5:19 Sunday 20th August, 2006
|
|
|
|
|
Maybe type of the exception is something different from OleDbException and as a result,the catch block won't catch it.Check typeo of the exception object.
If it's an OleDbException exception it has a ErrorCode property that usually contains the error code from OleDb provider (and it might be useful)
|
|
|
|
|
I changed type of exception to
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
But I still receive that Error Message. It seems It's not an Exception that
catch block be able to catch,it's look like the windows Error MessageBox
which has a windows Error notification icon.
-- modified at 5:17 Sunday 20th August, 2006
|
|
|
|
|
Hello
First of all, the error is thrown by the data provider. it's not an exception per se. That's why your catch block doesn't catch it.
Now, I think the problem could be in either your command string, or in the database itself -security permissions, data integrity, etc...-
First try to make the string this way:
string upCmdString = "UPDATE OutLetters SET LettPage=" + DocImage.ToString() + " WHERE LettId=" + LettId;
OleDbCommand OleCmm = new OleDbCommand(upCmdString, Conn);
OleCmm.ExecuteNonQuery();
If not, try to give your parameters a constant known value like numbers or letters that you know they should work, to test if the problem is in the input.
That's just to begin.
BTW : Don't forget to use the pre tags next time
Regards
|
|
|
|
|
Dear all,
Does any body know how to control Zooming in ObjectArx written in C#. Actually I am programatically selecting a Object in Autocad. Now i am issuing a Zoom command from C# - objectarx library. But this zooms the object very big(entire screen). I want to control this zooming, means decrease this. How can I decrease the zoom level.
Thanks...
|
|
|
|
|
Your best bet to to find a support board or forum that specializes in the component you're talking about. This is such a specific application, it's very unlikely you'll get ahold of anyone with experience with this component.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have a program that was written in VS 2003. The program runs fine without a hitch.
A few days back, I installed VS 2005. The program compiles fine, but everytime I run it, I got the an IllegalCrossThreadCalls Exception (something like its not reccomended to access a thread from another thread). Since I know for sure that my code won't cause any problems, I just want to turn off this exception.
I found the following code that does the job:
>> Control.CheckForIllegalCrossThreadCalls = false;
The problem is that this line doesn't compile under VS 2003 (the .CheckForIllegalCrossThreadCalls is specific to .NET 2.0).
I want my program to compile under both VS 2005 & VS 2003. So, I want to auto-detect the version of Visual Studio / .NET version. In other words, I would like to have a compiler directive that does this, e.g.:
#if (MAGIC_DIRECTIVE_CORRESPONDING_TO_VS2005)
Control.CheckForIllegalCrossThreadCalls = false;
#endif
Thanks a lot for your help. Any other solutions would also be welcome.
|
|
|
|
|
There is no DEFINE that tells you what version your compiling on. You're best bet to to actually fix the cross-thread call problem so it compiles under both legally, instead of barely legal under one and very illegal under the other.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
At first I want to say that I agree with Dave and suggest you fix the cross-thread call problem instead of suppressing the exception. Your program may run fine now but this can change and then you will eventually have a hard time to find the error origin.
Anyway back to the original question. You can use your example code and only need to define the MAGIC_DIRECTIVE_CORRESPONDING_TO_VS2005 symbol or something more handy in the settings of your VS2005 project. I make use of this pattern to have the ability of using generics or other .NET 2.0 stufF while my code still compiles for prior versions.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
The problem is that you're not calling the function on the right thread. This article[^] explains the problem and also offers a solution.
hongheo76 wrote: Since I know for sure that my code won't cause any problems
You might be under the impression that the code runs fine, and it may be true, but there also could be unpredicted results.
You're probably updating the UI from another thread. In this case, only the thread that created a control can access and/or modify its contents. Doing it from another thread could result in deadlock and other unpredictid results.
The right way to a control from another thread is to post a message to the application queue, and when that message is to be executed the control will get updated on the same thread that created it.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
Also, the way you were calling it was wrong all along. Not only in .Net v2.
The difference is that VS2005 generates an exception/or warning if you try to crosscall, probably because this was a mistake made by many using the Framework v1 and they were not aware of it.
I know I wasn't, since I only learned about it after using the v2 Framework.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
In order to determine what version is running call
Assembly.ImageRuntimeVersion
But like every one has said your code is wrong and you should not have cross thread calls. Whatever your doing with threading is volatile and should be fixed.
Also, by the way you can specify which CLR version to use for your app. I've never had a need to do it, but I know you can do it in the config file.
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Hello,
If you are viewing a site that authenticates the user from within a WebBrowser control, is it possible to capture the username and password? I want to use them to make a WebRequest later on.
I've been trying to get a NetworkCredentials instance with the supplied username and password, but so far no luck. I've tried using CredentialCache.DefaultCredentials and CredentialCache.DefaultNetworkCredentials, but both of their user/password fields are empty. Can anyone help?
Thank you
|
|
|
|
|
Hello
I'm not that expert in webdevelopment, yet I think you should extract that information from the webrequest sent when you press the submit button in the form.
For example in hotmail sign in form, when the user presses the sign in button your webbrowser control fires hte Navigating event. Here you can check the webbrowser document for field values. Check this psuedocode:
HtmlDocument document = this.webBrowser1.Document;
String username = document.All["userName"].GetAttribute("value");
String password = document.All["password"].GetAttribute("value");
Of course this implies that you must know the username and password field names, and that you put some error handling code -which I didn't in the above psuedocode-
Regards
|
|
|
|
|
Thanks for the reply. Unfortunately, the user/pass prompts aren't embedded in an HTML page - they're in a Windows-style login dialog that pops up when you click the login link. I'm not all that familiar with web development myself, and I don't know how the authentication works. I figured the authentication credentials must be accessible from the client that owns the browser control, but maybe not.
|
|
|
|
|
I have an ArrayList containing data where BOTH identical strings need to be removed.
program files\softsoftware\program\help\help3.htm,9/22/2006 2:22 pm
program files\softsoftware\program\help\help3.htm,9/22/2006 2:22 pm
|
|
|
|
|
If there's not a method to do this, sort them, iterate over them, and delete any that are the same as their neighbour.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you're sure there's only one duplicate you could simply call ArrayList.Remove twice.
arrayList1.Remove("program files\softsoftware\program\help\help3.htm,9/22/2006 2:22 pm");
arrayList1.Remove("program files\softsoftware\program\help\help3.htm,9/22/2006 2:22 pm");
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I have a function that when you move the mouse I need to tell my Panel to draw itself.
Thats fine calling Invalidate();
But when the size of the AutoScroll is larger than the panel. Calling Invalidate() sets the position back to the top.
I need to be able to update the screen ( calling paint ) and keep the same position.
I tried calling AutoScrollPosition after Invalidate but that didn't work.
I know I can keep track of the position manually, but isn't there some sort of function I can call instead of maintaning that?
Thanks,
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
What control is it that you call Invalidate on? If you want to redraw a single control, you shouldn't call Invalidate on the entire form.
---
b { font-weight: normal; }
|
|
|
|
|
then how should I trigger the paint event?
By the way its a panel in which I'm drawing on and no controls exist on it.
thanks,
nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Here's my question again, as it seems that you missed it completely...
What control is it that you call Invalidate on?
---
b { font-weight: normal; }
|
|
|
|
|
The Panel
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
What element is it that you have put the AutoScroll on, then?
---
b { font-weight: normal; }
|
|
|
|
|
How do you set it on an element? I dont see any property or method to do that.
The only thing that exists is a bitmap and I only want to scroll up and down because its huge.
A background might help.
I am making a map editor(level editor) for gameboy games. The map is 1024x1024 of 8x8 pixel squared. So I created a bitmap thats gigantic and I want to use the scroll bars to go to different parts of the bitmap. Then when I finished I will save the bitmap to a file.
The drag and drop and Invalidate work fine if I haven't scrolled.
But, as soon as I scroll the contents they get all messed up. So I need to refresh them. But, when Refresh or Invalidate is called the paint doesn't keep the position. I tried setting the AutoScrollPosition at the beginning of paint and that didn't work either.
I guess the solution is to override invalidate and hook the scrolling events.
I'm not sure and I don't do much winform devewlopment so I'm not sure.
Thanks for taking the time.
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|