|
//Insert record into database
conn.Open();
int iResults = cmd.ExecuteScalar();
conn.Close();
if (iResults == 1)
{
}
//The user record was found in the Database
else
{
//The user record was not found in the Database
}
When i debug, there's an error message saying "Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists(are you missing a cast?)
|
|
|
|
|
> "Cannot implicitly convert type 'object' to 'int'
You can't.
> An explicit conversion exists
It does.
> are you missing a cast?
You are.
It goes here: int iResults = (int)cmd.ExecuteScalar();
|
|
|
|
|
I recommend reading the article I link to in my sig, it will explain exactly how to solve these sort of error messages.
And, it's better to use int.TryParse and the ToString method, in general, b/c your code otherwise assumes that the value can be cast to int.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hi,
I have a native dll that I am interfacing through P/Invoke. I have created the API, but have no way to debug the native code. I tried using windbg for this, but couldn't figure out how. So, my current alternative is to have the native code print to stdout/stderr using fprintf. However, I can't find any way to see this output in C#. Is there a way to capture stdout/stderr output from the native code?
klk
madness ? this.isSparta = true : this.isSparta = false;
|
|
|
|
|
Hi,
what I tend to do in such case is I pass a managed delegate that takes a string and logs it somehow;
the unmanaged side accepts it as a pointer to a function that takes one char* as a parameter.
Each time I want to log some native thing, I call the function pointer, and the managed world
logs it (together with, and in sync with, the managed logging).
Hence no capturing stdout/stderr, just passing a delegate.
|
|
|
|
|
Hi Luc,
I did what you said, and got it to work - so now I can get debugging output sent to the console. Thanks!
It still feels like the old "printf" cycle of debugging (bug -> add printf -> recompile -> pray). Are there any guides on using WinDbg or another debugger to debug code that crosses managed->unmanaged boundaries?
klk
madness ? this.isSparta = true : this.isSparta = false;
|
|
|
|
|
Hi,
K.L.K wrote: I did what you said, and got it to work - so now I can get debugging output sent to the console. Thanks!
Fine.
You're welcome.
K.L.K wrote: It still feels like the old "printf" cycle of debugging (bug -> add printf -> recompile -> pray). Are there any guides on using WinDbg or another debugger to debug code that crosses managed->unmanaged boundaries?
I'm not an expert on WinDbg.
I tend to include such log statement right from the start,
and feel it saves me lots of hassles.
|
|
|
|
|
Hi
i want to use ocr technology to recognize unicode characters from images, i need a full article about this from basic to professional.
i searched over internet and also codeProject and find some useFul artciles, but nothing explained from basic, can anuBody help me ?
thanks
|
|
|
|
|
There's some good books at Amazon that go over OCR from start to finish. IT's still a major task, I assume most articles basically assume you have enough background knowledge to do it.
I can't find my book to give you the title, but if you search Amazon for image processing, you'll find it. Of course, the code is all going to be C, certainly not C#.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hi All,
I think I've tracked down my earlier Debugging issue. I think the way I have my external DLL's and References to them messed up. What is the correct way to handle this?
I've tried creating a Solution Folder called External_Libs and then added things in there, then my solution projects complain about not being able to load them. So I removed that folder and added in an External_Libs directory to each project and then added in the required DLL's into those and referenced them in those dirs and I still get the same error.
I wanted to keep all the external DLL's in a single directory (External_Libs) rather than having them all set to "Copy Local = True" then ending up with a mass of DLL's in the root directory.
Bit confused!!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
why do you want to creat a solutio folder, why don't you make a class library for the APIs you need? gather APIs in a project and build a single dll from that project. then you can add it by 'add reference' in any of your .NET projects.
if there is another error, check your used APIs whether they are correct or not at pinvoke.net.
|
|
|
|
|
The libraries I'm using are 3rd party like Infragistics and so on ... they are not designed to be built into another dll ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I have a custom control that inherits from ScrollableControl. I'm doing some drawing on the control and one thing I'm missing is a ScrollIntoView(Rectangle), where the rectangle corresponds to the same as Control.Location combined with Control.Size would.
I have tried grabbing PaintEventArgs.ClipRectangle or Graphics.VisibleBounds combined with Control.HorizontalScroll.Value/Control.VerticalScroll.Value and Control.Size, but these seem to include the area "behind" the visual parts of the scrollbars (ie. some graphics will be hidden behind the scrollbars).
How do I go about this?
Thanks!
|
|
|
|
|
Hi All,
I'm just doing my first installation check. The machine i'm installing my app on doesn't have VS or anything with which to debug things with, are there any solutions to this to find out exactly what is causing the problem? Is there some .NET tool to aid in this process?
Thanks,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Logging is the way. If your application logs, checking the log reports can findout what went wrong.
|
|
|
|
|
Yeah, I think I'm going to have to extend the logging ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
|
Ahh ... thanks!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Well, you may be able to attach a remote debugger and debug with that. This depends on security settings, but is probably the best way for you to do it.
|
|
|
|
|
Ok, i'll have a read up on remote debugging. Thanks Pete.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Great ! This is new to me. Thanks pete. My 5 for it.
|
|
|
|
|
No problems. You can find more info here[^].
|
|
|
|
|
|
Interesting idea!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
hi friends,
as you know, when you initialize a String, you can achive the characters by:
String str = "hello";
char character = str[0];
but i want to achive to the character without using any methods or facilities prepared in String class. how can i write a method to achive?
thanks
modified on Sunday, June 29, 2008 1:36 PM
|
|
|
|