|
Yes, I'm sure. You changed the type of test as well as its initialization. Of course it's going to be different.
|
|
|
|
|
|
I guess I could have been clearer..
And I'm still wondering what he actually wants to do.
|
|
|
|
|
He absolutely positively undeniably wants to make sure legseq is zero, I'd say.
|
|
|
|
|
harold aptroot wrote: And I'm still wondering what he actually wants to do. He is creating a security firewall to prevent external hacking that would make his int a string ?
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
What you are doing here is comparing a string " " to an integer.
This is not acceptable in C#.
You can compare legseq to 0 or convert legseq to string.
The default value of an int is 0 so if you dont assign anything to legseq, its value will be 0.
|
|
|
|
|
bigphish wrote: wch is wrking fine with Vb..
Which shows VB is absolute rubbish. You cannot compare apples with oranges.
You need to convert one of the two to the other type. (depending on what you want).
you could check out int.TryParse or the ToString method or the Convert classes. Each has it's own advantages.
oh and please. Loose the text speech and check your post for spelling before submitting. It's nicer for us the read
V.
|
|
|
|
|
Okie.. sorry if my code was unclear..
I am converting some code from vb to c#, wch will take some values from Oracle database and will insert in to a MS access database..so I cant view the oracle database wch is in some other server.legseq field in oracle database is taking data dynamically , which can be empty also some times.
so while inserting in to Access database I need to check if the value of legseq is empty.if it is empty i need to make it Zero before inserting.
hope its clear now..
|
|
|
|
|
You should almost certainly do this with DataAdapters and other useful things in System.Data instead of trying to convert the VB code verbatim. Handling of database nulls is something which I suspect will not work the same in the two environments anyway.
|
|
|
|
|
Better
My guess is that you need to check before you have the 'int leqseq' value.
Here are some things to look at:
- Can the value leqseq be null ? if so a nullable int (int?) or checking agains DBNull.Value is the best way to go.
then you can do this:
for int?
if(leqseq.HasValue){
}
else{
}
for checking against DBull.Value
- do you have a datatable, dataset, resultset somewhere?
in that case you can compare the database value against DBNull.Value .
if(mytable.Rows[rowindex]["columnname"] != DBNull.Value){
}
else{
}
If the value leqseq cannot be null in the database
you need to test if has an invalid 'value' like 0 or -1 or something, but this is bad database design. In that case you don't need a string either, but just compare against the 'fake' value.
Hope this helps.
V.
|
|
|
|
|
I don't know how you are retrieving the values from the Oracle database, but ADO.Net DataReaders have an IsDBNull property, which can be used to check if a result is null, so you can do something like this :-
count = dr.IsDBNull(0) ? 0 : (int)dr[0];
and that will give you a 0 if the result is null, otherwise will return the value (assumes your data reader is dr ).
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
yes .Thanks alot for the help
|
|
|
|
|
The compile error message says it all. You cannot implicit compare integer datatype to string datatype
To get your code to compile you can use:
int legseq = 0;
if (legseq.ToStirng() == " ")
{
legseq = 0;
}
However, that if-statement will ALWAYS be false and legseq will never be assigned to 0.
What you're trying to do make no sense. You might be looking for:
int legseq = 0;
if (legseq != 0)
{
legseq = 0;
}
For me it looks like you have not looked and though over your program flow in your code.
/Steffe
|
|
|
|
|
Hey there,
I am writing an owner drawn listbox control. This is based off of Mike Hankeys Extendable ListBox[^].
I have already modified his code greatly to fit my needs, but I would like the list box to 'auto-center' on the selected item when I click, and the index gets changed. As far as I can tell the only method for doing this is to modify the TopIndex. Is there any way to tell what indexs are viewable so I can just seek up/down a couple and say.. make sure this one is visible as well? Or am I just not looking at this correctly?
And while I am on the subject of scrolling. Any way to make it scroll smoother rather than jumping?
modified 12-Jan-12 12:29pm.
|
|
|
|
|
Hi,
yes TopIndex is the way to go.
If the item height is constant (DrawMode.OwnerDrawFixed), the properties Height and ItemHeight should let you calculate how many items are visible at once.
if the item height is variable (DrawMode.OwnerDrawVariable) you had to provide a way to calculate the height (MeasureItem event), so you could use that method to decide how you want to spend your ListBox height.
For softscrolling, you would need access to the scrollbar itself and set its value, rather than TopIndex; I haven't done this, and I expect the ListBox to overrule you. You might have to replace the ListBox by a big-panel-in-autoscrolling-panel approach (this[^] could serve as a starter).
|
|
|
|
|
Getting a list box to do exactly what I wanted was annoying enough that I wrote this control[^], which may be of use as an alternative starting point. I think scrolling was one of the things I had trouble with too.
|
|
|
|
|
Hello,
I would like to wrap a text file into my project, and copy it out to a directory when a button is clicked. My current project is a dll plugin. Is there a way to have a folder inside of the solution explorer to hold these files, and then to be able to copy them out of this folder (which lives inside of the dll) to a directory?
If this is not possible, what is the most efficient way to write a text file, where carriage returns and spacing are crucial? It's a couple of hundred lines, so it'd be pretty tedious to write a string like the following which I was hoping to avoid and only use the below as a last resort.
string fileContentsLineByLine= "test" + System.Environment.NewLine +
"test2" + System.Environment.NewLine +
"test3";
Thank you for reading.
|
|
|
|
|
You can add the file to your project's resources and access it from there at run time.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the reply!
How can I reference it in the resources directory or is there a term for this I can google to see examples?
|
|
|
|
|
Take a look at this MSDN article[^] for full details.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thank you Richard! That article was very informative, although I have one more question.
I was able to get this to work with a bmp file, but I cannot seem to get it to work with a text file, or exe or dll?
With the bmp file, I can use the following code
System.Drawing.Bitmap bitmap1 = Project.Properties.Resources.bmppicture;
bitmap1.Save(theDirectory + @"\" + @"Fdr\bitmap1.bmp");
Scratch that, File.WriteAllBytes() works for txt files
Is there a way to Dllimport from an embeded dll that is inside of the resources folder?
modified 12-Jan-12 15:03pm.
|
|
|
|
|
turbosupramk3 wrote: Is there a way to Dllimport from an embeded dll that is inside of the resources
folder?
Question isn't clear.
Given that you have a dll named X.
And you want to embed X into your application as a resource?
If the answer to that is yes then why would you want to do that?
|
|
|
|
|
Hi,
I'd like to not only embed it as a resource, but load it into memory from the embedded location so that I don't have to copy it anywhere when I import it. This particular dll is unmanaged Delphi code, in case that matters.
|
|
|
|
|
turbosupramk3 wrote: I'd like to not only embed it as a resource, but load it into memory from the embedded location so that I don't have to copy it anywhere when I import it. This particular dll is unmanaged Delphi code, in case that matters.
I doubt there is an reasonable reason for doing that. Some possible reasons.
- To 'protect' it.
- Unable to figure out how to access it.
- It won't run with the normal load
None of those are valid.
But regardless achieving it is going to be difficult. It is going to require a lot of code and lot of expertise and even an expert in several languages is going to have a difficult time getting it correct (bugs that do not cause failures.)
Some links that follow. (Keep in mind licensing concerns when looking at the code.)
http://delphi.about.com/od/windowsshellapi/a/delphi-load-resource-dll-into-memory.htm[^]
http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/[^]
|
|
|
|
|
You are right, this is more advanced then my skills ... thank you for the information.
|
|
|
|