Posts by Pedro Paulo • 3,651 points
138 posts
-
1
votes1
answer47
viewsA: Reorder numerical sequence when changing array position
As I mentioned in the comments, I would say to evaluate a better way to do this, because if the user clicks several times on the button, it is several calls to the database. I can’t suggest anything…
c#answered Pedro Paulo 3,651 -
1
votes1
answer35
viewsA: System.Indexoutofrangeexception: Index outside matrix boundaries
This error says that you are trying to access a non-existent index in the array. Example: we have an array of integers with 5 values, that is, to access the first element, we start at index 0,…
c#answered Pedro Paulo 3,651 -
3
votes1
answer52
viewsA: Best way to query the database using LINQ and Entity Framework
The part where you take the Email from the first item of the contact table I can’t say if it is right or wrong, because it depends a lot on the business of your system, that is, only you could say…
-
1
votes1
answer41
viewsA: How to assign a class to one of another Class
From what I understand from your question, you are creating an algorithm (probably for study) to simulate a game. You have a player (Player) who may have one or several items. For this you need your…
-
2
votes1
answer414
viewsA: HOW TO PERFORM FUNCTION EVERY TIME PERIOD - UNITY
Use the function InvokeRepeating(string methodName, float time, float repeatRate); The first parameter is the method you want to call. The second parameter is the waiting time before calling the…
-
1
votes2
answers86
viewsA: How best to separate the two lists in C# by doing an operation with each side of the split
The Rovann solution works perfectly for your scenario, and LINQ makes the code "more beautiful". But use the .ForEach LINQ is much slower than using the foreach conventional, which in turn, in most…
c#answered Pedro Paulo 3,651 -
3
votes2
answers57
viewsA: How to insert separate data?
You can add the description column conditionally, that is, only if your variable representing the description value is filled in that we will insert the data in the column. MySqlCommand command =…
-
2
votes3
answers93
viewsA: How to find certain words inside a string in C#
From the comment you made in @Catarina Batista’s reply, I understood that you would like to create a custom method to search all the parameters of your query and then customize it your way. I made a…
c#answered Pedro Paulo 3,651 -
11
votes3
answers1856
viewsA: How do NOT differentiate upper and lower case with index?
Make the contents of your variable name and the parameter of indexOf uppercase or lower case. Capital // Exemplo em maiúsculo if(name.toUpperCase().indexOf("CARRO") !== -1) { alert("existe"); } else…
javascriptanswered Pedro Paulo 3,651 -
1
votes1
answer281
viewsA: Error while trying to popular a List
Create two separate variables to analyze better while debugging your code. In the first variable we will store the query with the accounts to pay. No Select we will create an instance of your class…
-
1
votes1
answer185
viewsA: Controller receiving null parameters
You are performing a POST in your page form. So that Submit sends the data to the server and its Controller recognize the parameters of your class ConfSistMOD, we need to name the fields within the…
-
1
votes7
answers1103
viewsA: Remove part of string until nth occurrence of a character
As his string will always be divided by the character >, we can say that we have a pattern, with this, we can divide using the method Split(). // Aqui temos nossa string original dividida pelo…
-
4
votes2
answers168
viewsA: Remove array item when unchecking checkbox
Create a condition to remove if it already exists in your array: if (valores.indexOf(event.target.value) === - 1) { // Se o evento não está presente no vetor, nós o adicionamos…
-
1
votes2
answers192
viewsA: Separate COM object from adjacent RCW
You created and opened your connection, but when creating the OleDbCommand you are not associating it to your open connection, that is, this command refers to what connection? I made a code snippet…
-
8
votes2
answers1072
viewsA: What use is Notmapped?
When we are creating an application using the ORM Entity Framework, we can use the Code First in which we model the application and from which our database will be generated. To model the tables in…
c#answered Pedro Paulo 3,651 -
6
votes2
answers236
viewsA: Remove unwanted characters from a List<string> without going through the list
We can use the Linq to effect the modification of string more simply, because from what I understand you want to remove the loop for. Below is the example with Linq: using System.Linq; lista_strings…
-
5
votes4
answers766
viewsA: How do I capture only the last 2 digits of the current year?
first form Knowing that the year is composed of 4 characters, we can use the method Substring() to pick up all the content from the second character of our string: // 2019 - Iremos pegar a partir do…
c#answered Pedro Paulo 3,651 -
4
votes2
answers602
viewsA: Return Zero in Function Mysql if query is NULL
Use the function COALESCE() that is standard ANSI (standardization of similar functions for all DBMS). Your query does not bring any lines, so we will do a sub-query that will return us null, with…
mysqlanswered Pedro Paulo 3,651 -
10
votes4
answers1049
viewsA: String list + . Split()
The method Split() returns an array of string, to turn into a list you would have to convert it, for this you can use the method .ToList();: string texto = "1;2;3;4;5"; List<string>…
-
2
votes1
answer83
viewsA: replace javascript do not differentiate uppercase or lowercase
Use Regex to solve your problem: var textoAlterado = locationHref.replace(/O=OrderDesc&/ig, ''); The syntax for regular expression is /padrão/flags, flags being our parameters: i: ignore capital…
javascriptanswered Pedro Paulo 3,651 -
4
votes1
answer512
viewsA: Error: Cannot convert Implicitly
I believe your variable long products be the identifier of the product you want to find. When you perform the filter by method Where(), you will get a collection of data, be it a IQueryable or…
-
2
votes2
answers81
viewsA: How to get multiple Abels to have a randomly generated number
The @Leonardol explanation is very good for your problem! But I will leave an additional code to solve another type of problem if it occurs in your scenario. Leonardo’s scenario will work very well…
c#answered Pedro Paulo 3,651 -
0
votes1
answer69
viewsA: Enable Jquery function when x characters
I left two code options on Jquery, when you hit 6 or more characters will be called the button action or submit the form. Observing: You did not give details of the names of your controls, change to…
-
0
votes1
answer501
viewsA: Use in select percentage in Firebird
Use basic math to solve the problem. 100% - 2% = 98% 98% = 98/100 = 0.98 We have that 98% represents 0.98 Just change the query to use this calculation: SELECT (0.98 * T.valor) as TOTAL FROM…
-
-1
votes2
answers461
viewsA: Disable button while request is performed
Replace your request to $.ajax. In it we have the functions: beforeSend: this function is executed before the request is made AJAX, in your case, here we must disable the button. success: this…
-
1
votes1
answer73
viewsA: How to open a Form( or hide a Form) inside a Panel by another Form
The problem is that you need to take your current instance (which is created and saved in memory) from the class frmPaginaInicial, so the rest of your code will work normally: // Aqui pegamos a…
c#answered Pedro Paulo 3,651 -
7
votes3
answers3455
viewsA: Converting integer to string in C#
Use the extension method ToString(): int numero = 10; string numeroString = numero.ToString(); An observation, if your entire variable accepts null values and is null, when using the method…
c#answered Pedro Paulo 3,651 -
1
votes2
answers650
viewsA: Save file with openFileDialog
The class OpenFileDialog owns a property called FileName, it contains the complete directory + the name of the selected file. Change your code to use FileName instead of InitialDirectory, in the…
-
0
votes2
answers40
viewsA: Reset Divs id by numbers in order
We can use the function each (function that performs a loop) to traverse all div of our HTML. This function will loop all Divs (we specify that it will be on Divs in the command $(div)), and we also…
-
4
votes1
answer1343
viewsA: How to change 2 or more columns at the same time in Sql Server 2014? (ALTER TABLE/ALTER COLUMN)
You can do more than one command to add ADD or remove DROP COLUMN, but cannot stop the ALTER COLUMN. The command ALTER TABLE does not allow you to make more than one ALTER COLUMN, that is, you will…
-
5
votes3
answers2862
viewsA: Changing data from a List<>
If you know the index of the element you want to change, you can do as per @Robertodecampos' comment. // Vou preencher somente o Identificador neste exemplo List<Produto> listaProdutos = new…
-
5
votes4
answers2042
viewsA: Select with 3 tables in SQL SERVER
Just add one more INNER JOIN with the other table of Marca: SELECT * FROM tblMaquina maq INNER JOIN tblEquipamento equi ON equi.equId = maq.maqTipoEqui; INNER JOIN tblMarca marca ON equi.marcaId =…
-
1
votes2
answers76
viewsA: How do you capture the time in a String?
Goes below: var horariosFormatoInicial = '11:11 as 22:22 / 33:33 as 44:44 / 55:55 as 66:66'; var horariosSeparados = horariosFormatoInicial.replace(/ as /g, ' / ').split(' / '); var saida1 =…
-
1
votes1
answer48
viewsA: Mapping with Entity Framework
The method HasKey has a signature that has as parameter a delegate that receives its entity as parameter and returns a object. This means that the content you return (in theory can be anything…
-
0
votes4
answers2917
viewsA: Filter using only month and year on SQLSERVER
Just filter the dates between the first and last day of the month. No need to use functions to filter month and year and you can use this logic. --Primeiro dia de Janeiro (01/01/2017) até o último…
-
1
votes2
answers222
viewsA: How to take out the commas and insert spaces between the numbers in this array?
Use the function join(caracterSeparador) to add the separator character between each array item. Example: var arr = []; while (arr.length < 4) { var r = Math.floor(Math.random()*16) + 1; if…
javascriptanswered Pedro Paulo 3,651 -
0
votes1
answer36
viewsA: Mysql_error when resetting root password of MySQL_"Error when establishing a connection to the database"
Search for the file wp-config.php in the root directory of your website Wordpress and change the database access credentials. It must be something like this. /** Nome do banco de dados para o…
mysqlanswered Pedro Paulo 3,651 -
1
votes2
answers48
viewsA: Entity framework 6.2.0 + Find
Use the method DbFunctions.TruncateTime(data) to use date and skip time. Where(x => DbFunctions.TruncateTime(x.Data_Intencao) >= Periodo.Date && c => c.SubOrigem_EF);…
-
1
votes2
answers44
viewsA: Inserting data from a datagridview c# in another datagridview giving 2 clicks
It turns out that every time you fall into this method you have a new instance of ProdutoColecao, so you’re not persisting the data she already owned. The solution to the problem is for you to…
c#answered Pedro Paulo 3,651 -
3
votes1
answer1319
viewsA: "ORA-01756: quoted string not properly terminated"
The content between single quotes identifies that that data is text (for databases), so when you have some text that has simple quotes, you need to add the escape that is a single quote more.…
-
0
votes1
answer162
viewsA: INSERT WITH JOIN DUPLICATING DATA
By the name on the field cod_venda_item, I’m guessing it’s a Primary key with the identifier of each item in that particular sale. Add to your query a LEFT JOIN with the same table being made the…
-
0
votes1
answer239
viewsA: How to update listbox from another Form?
There is a problem in understanding object instances. What is a class? Roughly, imagine the class as a design of a car or a plan of a house, in it we have defined the characteristics (attributes)…
-
1
votes3
answers264
viewsA: Select Group by Month
The function MONTH(data) receives a date as parameter and returns the month of the date reported. You are already grouping your query by month and are adding the values grouped, now all you need to…
-
4
votes1
answer48
viewsA: I have a panel in aspx, but gives error in code Behind(Web Form)
Probably this panel was created when the project was running, so no reference was generated for it in the file NomeDaSuaPagina.aspx.designer.cs. It needs to be a similar reference in the page…
c#answered Pedro Paulo 3,651 -
4
votes3
answers237
viewsA: Query SQL Add duplicate value
Group the result by barcode using the clause GROUP BY and use the aggregation function SUM() to sum these grouped results. Modify your query to look like this: SELECT CODIGO_BARRAS.barra,…
sqlanswered Pedro Paulo 3,651 -
1
votes2
answers351
viewsA: Sum values from a column in the database via date filter
The problem is because MYSQL does not accept white space between the function name and parentheses, in which case sum (quantidadeVagas). Change your query by removing the white space between the SUM…
-
2
votes2
answers150
viewsA: Add values from a select when repeat client id
Group the result by user name using the clause GROUP BY and use the function SUM to sum these grouped results. Modify your query to look like this: $sql = "SELECT nome, SUM(valor) FROM clientes…
-
1
votes2
answers88
viewsA: Substr() does not work
The function CONCAT in your query is misspelled, change it which will work: $consulta = "SELECT CONCAT(SUBSTR(nome,1,10),'...') AS nome FROM produtos";
-
6
votes3
answers1590
viewsA: Check that all fields of an entity is null
Let’s create an extension method to validate if our Viewmodel has any null property. To start we will create a base class so that all our Viewmodels inherit from it, so we can distinguish our…
c#answered Pedro Paulo 3,651 -
0
votes3
answers123
viewsA: Validate javascript line
First we will remove the id="autoriza" of their select, because they’re duplicated and that’s a problem. Now we will add a new class to your select so we can recognize them in Javascript. Put all…
javascriptanswered Pedro Paulo 3,651