DataReader: pass a parameter as a String with case change does not give results - winforms

I've a DataReader which its Command involves a LIKE clause. For it to be executed, a String is passed as a paremeter from a TextBox at the UI. All data in the DB is stored as UpperCase strings. The scenario I face is as follows:
If the user inputs an Uppercase String at the UI, the DataReader gives results without problem
I've tried to give a sort of "protecction" to the input, so if the user inputs TitleCase or LowerCase, then the query still works as intended. Yet, when I use CultureInfo.CurrentCulture.TextInfo.ToUpper(myTextBox.Text) or
myTextBox.Text.ToUpper() , if I check the debugger, it even shows that the parameter is changed to UpperCase, yet, the dbConn.dbCommand.ExecuteReader() sends no results.
Could anyone give any hint or explanation of why this is not working? (and suggest a solution).
Thaks a lot in advanced for any help.

Related

Get each item in a collection with one query

I have a collection of slugs and want to get each corresponding page with one query.
Something like ...
Page::whereIn('slug', $slugs)->get();
... does only return the first page matching any slug in the collection.
Currently there is a loop, but that are dozens of queries I want to avoid.
Try using the whereRaw method and imploding your array into a string:
Page::whereRaw('slug IN ("' . $slugs->implode('","') . ')')->get();
As it turned out, whereIn was the right way. There was one minor mistake in my logic, and at the same time insufficient seeding data, that blowed everything up.
If someone does not know: whereRaw should be used with caution. To avoid SQL injection vulnerability, all user-submitted entries have to be passed as parameters.
Page::whereRaw('slug IN (?)', [$slug]);
Beware: Wrapping ? with quotes is a syntax error. The passed data will be single-quoted by default, at least on my machine™.
select * from `pages` where `slug` in ('page');

Is there a way to sort a no. of character arrays in alphabetical order without using the #include<string.h> or #include<stdlib.h>?

So, I have tried to do the same in a case of array of structures where 'char name[100]' is the only data member.
1st part of the code
2nd part of the code
The problem that I have encountered here is that once I provide a no. of names during program runtime, the output screen either does not print anything afterwards, or, prints the data without sorting it.
output screen
I did not get any compile time errors so I believe that there is a flaw in the logic.
There's this another method I tried hoping to get positive results. I type-casted characters to integers hoping that ASCII values could be used to compare. But, the results are exactly the same (undesired results).
updated logic of the 2nd part of the code
I hope somebody helps me find a way to correct this logic or provide another logic that is efficient.
the sorting logic you used is good , but from what is see the use of function's in C need's to be provided by pointers. other wise all the data inside the function will born and die inside the function , and the all the variables in the Main will stay the same as given, that explains why the output is the same as the input
try to print inside the sorting function's to see if this is the problem.

How would I check If a role has a certain word in it discord.js

I have this code so far which does not work.
if (member.roles.cache.some(role => role.name.includes === 'Gang‏‏‎ ‎'))
basically I have like 9 different roles that all have the word gang in them and instead of checking if a user has each role individually I want to check if they have any of the roles all at once. since it will save space and be less of a headache. is there any way to do this effectively? I'm open to all answers, thanks for the help.
The includes method is defined on the string prototype and takes the search string as argument (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes).
While your current code compares that method to the string literal 'Gang ' you instead want to provide the search string as an argument like this: role.name.includes('Gang‏‏‎ ‎')

Validation rules in access

I recently started learning and using microsoft access. However, I am afraid that there is something really bothering me. It's connected with the validation rules. So here is my problem:
I had to validate a field so that only letters could be written. Of course I googled it and found the proper syntax. (Is Null or Not Like "*[!a-z]*")
At first I tried with (Is Null or Like "*[a-z]*"), which I think should be the same as the above one. It's checking every symbol from the string whether it is between 'a'and 'z' and that is why it is used with the obelisk * symbols from the both sides. Am I right?
My question is: Why is the second one not working, although it is a double negative equivalent to the first one. Will be happy for any explanation. Thanks in advance!
P.S Sorry if the question seems useless for you but I really do want to figure out where I am mistaking.
Consider the string 'a1b'.
Like "*[!a-z]*" will search the string for any character that is not in the range 'a'..'z'. It finds the '1' in the second position and returns True. Therefore, Not Like "*[!a-z]*" returns False.
On the other hand, Like "*[a-z]*" searches the string for any character that is in the range 'a'..'z'. It finds the 'a' in the first position and returns True.

How to select options based on character user input stored in an array in C?

I may have worded that strange, but if you need clarification I can provide it. I'm a complete noob to coding and am learning to use C language.
I have printed out a menu of options for the user to select. The user input is read and stored into a character array. I then printed out the string back to the user. So far everything works to this point.
My issue is selecting an option based on this character input.
I tried using strcmp inside if-else statements but never get the correct output.
Can someone point me into the right direction?

Resources