Click here to Skip to main content
14,924,456 members

Comments by jsc42 (Top 30 by date)

jsc42 28-May-21 17:43pm View
What is the value in RecordID when the query is created? What creates it / updates it?
Have you tried stepping through the code and looking at the contents of the variables?
jsc42 31-Mar-21 16:57pm View
Your code is incomplete. You need to add

* add your environment here

One of the few things I remember from doing COBOL is that the order of the divisions is I(dentification) E(nvironment) D(ata) P(rocessing) which creates the mnemonic i.e. DP, said as "That is Data Processing"
jsc42 18-Mar-21 13:06pm View
Should 'f(i, ref j);' be 'f(i, out j);'?
jsc42 11-Mar-21 5:16am View
Are you trying to create a string with "&Hxx" texts in it, as per your description; or an array of bytes as per your sample code?
If it is the string, then you can do a simple text conversion e.g. Dim byteString As String = "&H" & inputString.Replace("-", ", &H")
If it is the array of bytes, then I'll let someone else reply as the technique is slightly harder and will need something in a 'Solution' section rather that a 'Comment' section.
jsc42 1-Feb-21 15:18pm View
I have not looked at how you are following the nodes, but there is a problem with your RegEx expressions.
1) You are enclosing your URLs in '[' and ']'. Those delimiters mean 'match any character in the list' s, for example, [] would match a single character the is any of w, d, i, g, k, a, l, ., c, o, m, /, or r (I've dropped duplicated characters). To match the URL as a string, drop the '[' and ']'. You can keep the '(' and ')' if you want to use subgroups.
2) As you are not using '^' and '$' to anchor at the start and end of the texts, some of the tests will not givemn what you expect e.g. your regex9 will catch anything that also matches regex10 through to regex15 as it contains a subset of all of them.
Also, your 'if' statements are wrong. 'if (res1=true)' will assign the value true to res1 and then the 'if' will see if res1 is true. Ir will always be true as you have just assigned it the value of true. To compare, use '==' e.g. 'if (res1==true)', but since 'if' is comparing the expression for truth anyway, all that you will really need is 'if (res1)'. Ditto for all of the other 'if (resn=true)' when n = 2 to 14.
jsc42 6-Jan-21 10:15am View
Try changing your
File.WriteAllText(Path.Combine("Results" + myDate, "Bad.txt"), "listBox1.Text");
File.WriteAllText(Path.Combine("Results" + myDate, "Bad.txt"), listBox1.Text);

i.e. getting the text from lstBox1 rather than writing the literal string "listBox1.Text"
jsc42 3-Dec-20 9:33am View
I'd be very wary of hooking into standard DLLs. You cannot know how it might affect other applications and there may be issues if the DLL changes. My only thought re Chrome / Edge etc is that most browsers have a print option to not print the background of a web page. Is it possible that some of the call(s) that you are intercepting to create your watermark are for generating the web page backgrounds that the browser option is then discarding?
jsc42 26-Nov-20 13:12pm View
I cannot answer your question, but there is redundant code in your sample. The 'if (Request.IsAuthenticated && empId != null && Id != null)' leads into a block that includes 'if (Id == null)'. If it gets to the 2nd 'if', then the 2nd 'if' then Id must not be null, so the 2nd 'if' is always false.
jsc42 16-Jun-20 4:26am View
You cannot enter an infinite number of numbers - it would take the whole of eternity to do it. Do you mean that you can type more numbers than you want? Does it find the solution for every number that you type or just the first one that you are searching for? My guess is that it will only search for the first one and the rest will be ignored. This is because you are just filling in data into a scan buffer and your program is consuming data from the scan buffer. Data not relevant to the program (e.g. your infinite set of numbers) just sit there waiting in the buffer in case any code wants to scan them. However, if you are entering multiple numbers and each is being searched in turn, please verify that the code that you have posted is what you are running and that there isn't another loop somewhere that is picking up the other numbers.
jsc42 18-May-20 12:40pm View
As is, the query would find rows where column 'column' does not have any letters in the range A to Z. I guess the OP is looking for rows where column 'column' only contains the letters A through Z, which is a lot trickier. Even if the correct LIKE is used, it wouldn't eliminate anything, it just wouldn't select specific rows to be returned in the query
jsc42 4-Jan-20 12:33pm View
Also check the size of the field in the database that the data is being saved into. A large image will need a large amount of storage and (as has already been mentioned) converting to Base64 inflates the size by 1/3. If the resultant size is bigger than the max size that the field can hold then the database update will fail.500Kb will need a field that can hold 682668 bytes.
jsc42 28-Oct-19 7:35am View
I've learnt something new today, having looked at your SQL. I did not know that the ELSE clause in a CASE was optional. I've looked it up and the docs say it defaults to ELSE NULL. I think that I'll still always put an explicit ELSE in my code just to confirm that I've at least considered the possibility; but that is the exciting thing about reading other people's code - there is always new things to discover or new ways of doing old things.
jsc42 28-Feb-19 6:28am View
You say "in the designer radiobutton is empty". This is to be expected. The Form Designer shows the design of the form, not what happens at runtime.
jsc42 15-Jan-19 4:17am View
Even if you can connect, you must be aware that there are many SQL Dialects and versions; so you would have to code variants for different systems.
jsc42 2-Jan-19 16:56pm View
Capture the actual error code from the 'write' and include it in your error message. Then look up the code - that should give you a clue as to what the error is.

int errcode;
if ((errcode = write(sockfd, sendline, strlen(sendline) + 1)) < 0)
printf("The write function returned %d\n", errcode);

Also, I suspect that you might need an '&' before the recvline argument in the read function (happy to be corrected if I am wrong).
jsc42 28-Nov-18 3:43am View
Look closely at your transliteration, you've missed something (clue: it is in the 'while' clause).
jsc42 15-Nov-18 5:31am View
Multi-threading is the correct way to go, but as a quick hack you can (often, but not always) get away with Application.DoEvents. If you do go down this slightly risky route, disable the Save button when pressed and reenable it when saving is completed; otherwise impatient users will keep pressing it.
jsc42 8-Nov-18 16:56pm View
The PNG has a formula like

sum = x + (x^2)/2! + (x^3)/3! + . . . + (x^N)/N!
(where I am using ^ as the exponentiation operator)

You need to understand the ! (factorial) operator and the fact that this is an infinite sequence (the N represents a sufficiently large number). Any reasonable Computer Science text book will tell you how to handle infinite sequences. Hint: Do not blithely get the terms and add them; you will need to think about the pattern between the adjacent terms. If you think about what the parts in the terms are doing, you will see why.
jsc42 26-Oct-18 5:21am View
I think that the OP knows what is the problem with the code. His / her qn was how solutions to the problem submitted by examinees can be tested safely.
jsc42 25-Oct-18 3:56am View
This is known as a Pivot Table. Google it - there are a lot of possible solutions for SQLServer as that does not support them out of the box. However, the solutions are not easy.
jsc42 25-Oct-18 3:52am View
I am not sure what you are trying to achieve. Are you trying to truncate numbers at 4 dec places or to display them with 4 dec places. Please tell us the expected output and the actual output.

I have tried your code in SQLServer and your 2nd col produces zeros for all values except for 18.26 which gives 2.91038304567337E-11 which is almost zero - this will be a rounding error. Float will always give inexact values as the binary value is only an approximation of the decimal value which is something you must be aware of when working with float values (in any language, not just SQL). All of the values will have rounding errors but some will be too small to display so they are shown as 0.
jsc42 10-Oct-18 8:06am View
As @CHill60 says, What error?

There are a million and one possible error each with different causes.

My wide guess is that you have fields EMP_NO and / or group_name present in multiple tables so Oracle doesn't know which one to use. Try using qualified names, e.g. em.EMP_NO and gi.group_name (if they are in emp_master and groupinfo respectively, otherwise adjust as required).
Or is EMP_NO numeric? In which case you may need to cast / convert to text if gi.group_members and v.DIR_EMP_NO are texts; otherwise if they are all numbers, convert the concatenated string expressions to arithmetic expressions (exact formula depends on whether EMP_NO has a constant no of digits excluding leading zeros or not).

In summary ... please supply more information as we cannot guess exactly what you arte trying to do.

I'll leave it to someone else to comment on using expressions rather than simple column names in join clauses.
jsc42 10-Oct-18 7:53am View
How are you invoking the page? If you have it locally and are double-clicking its filename from Windows Explorer or right-clicking and using 'Run Using ...', it will load with a 'file:' protocol. This does not seem to be honoured in Edge but is honoured in Chrome. I do not know if it works in IE11 - it used to work in earlier versions of IE. If you are running it through a web server, then I cannot help.
jsc42 6-Oct-18 11:52am View
If you are only concerned about the first two chars, why are you comparing the whole strings? Wouldn't it be easier just to check the first 2 chars if that is all you want, e.g. if (temp1[0] == str[0] && temp1[1] == str[1]) printf("same\n"); else printf("different\n"); ?
jsc42 12-Sep-18 8:40am View
Minor Typo: in the list of 2 digit combinations, the values should be
12, 21, 15, 55, 59, 98
jsc42 16-Aug-18 7:39am View
@OriginalGriff's solution checks the whole field in one go, so change the #().keypress to #().change (I'm not a jQuery expert) and test the field value rather than the event keystroke.
jsc42 24-Jul-18 8:16am View
Why are you manually counting no of rows returned? You don't use the fields, so it would be better to do
SELECT COUNT(*) AS nRecs FROM prrr1 WHERE username = @Username AND pic = @Image
(this is assuming you use Nathan Minier's advice to parameterise your expression) and then just get the count directly
jsc42 7-Feb-12 10:04am View
My trusty "JavaScript - The Definitive Guide" (1998 - 3rd Edition) agrees with your basic premis that '.' is "Any character except newline, equivalent to [^\n]". So, [.\n] is adequate; you are correct in omitting the '|' - that was my bad! I suppose that [.\s] would be belt-and-braces just in case you were generating text on a Windows system and processing it on a Unix system and that the RegExp coders had forgotten that Windows uses \r\n instead of \n.
jsc42 3-Jan-12 7:11am View
For ordering ascending, try changing
AND cte.[Rank] < cte.[Count]
AND cte.[Rank] > cte.[Count]

or try changing
, Models + N' , ' + Model
, Model + N' , ' + Models

I don't have SQL Server, so I cannot test either of these two possible solutions. I would be interested to know if either / both work.
jsc42 25-May-11 12:56pm View
Many style gurus suggest comparing strings against variables, instead of comparing variables against strings just so that compilers would catch the mistaken use of '=' instead of '=='. Viz:

if ("Manager" == UsernameTextBox.Text && "Maintenance" == PasswordTextBox.Text)

which is valid whereas

if ("Manager" = UsernameTextBox.Text && "Maintenance" = PasswordTextBox.Text)

is invalid.

Personnaly, I think it looks clunky and awkward. Anyone who uses that construct is already aware of the issue of confusing '==' and '=', and hence probably does not need this backward construct. Conversely, people who are likely to fall foul of '=' instead of '==' are unlikely to be ones who would use the backwards construct. But I am sure there must be a set of people somewhere that would benefit fropm this backwards construct.