Posts by Pedro Paulo • 3,651 points
138 posts
-
2
votes2
answers2020
viewsA: Split String with . Split - C#
Try to use the method Substring, would look like this: string resultado = caminho.Substring(caminho.LastIndexOf(@"\") + 1); Explanation: the method Substring has the function of returning us some…
-
1
votes2
answers219
viewsA: C# - Initialization of an array/list
You can create an extension method to popular your collections. Create a static class with a static method to become an extension method: public static class Extensions { /// <summary> ///…
-
1
votes1
answer84
viewsA: How to bring a city relationship into operation?
It depends on how you desire your relationship, if you are following the line that an Employee is in a City and a City has multiple employees, the relationship would be as follows: public class…
c#answered Pedro Paulo 3,651 -
0
votes2
answers929
viewsA: How to use async/await in void return methods?
Just declare your method as async and put the type of return Task, that would be a void multithreaded. Below is an example: using System.Threading.Tasks; using System.Net.Http; public async Task…
-
2
votes4
answers4389
viewsA: Select from previous months
We need to filter the last 4 months (as per your comments) from the current month of the system. We use the function DATEADD(MONTH, -4, CONVERT(date, GETDATE())) to subtract 4 months from our…
-
1
votes3
answers80
viewsA: How to deal specifically with a Keynotfoundexception?
You can use the method Containskey, in which you pass the key who is searching and will be returned whether or not she exists in your collection Dictionary. string idFormaPgto = "1"; //Se a key…
c#answered Pedro Paulo 3,651 -
1
votes2
answers1221
viewsA: Javascript: How to insert multiple whitespaces into a paragraph <p> element?
You can use the function padEnd to add the character you want when the defined size is not filled. Here we are defining that the text of our tag will be itself plus the character ' ' when the size…
-
-1
votes1
answer448
viewsA: prime numbers from 0 to 10 in mysql
Since the prime numbers between 0 and 10 are few and it is a mathematical rule, that is, something exact, we can use the fixed code to verify if the number is prime: Number of primes between 0 and…
-
0
votes3
answers636
viewsA: Average all records in a table and update column in MYSQL
Add the average calculation in your update, but if your field is type integer the average will ignore the decimals, for this reason I am adding a CAST AS DECIMAL for your average field consider the…
-
1
votes2
answers1286
viewsA: Sort date by month
You can use the function MONTH to return you the month of your date and order the return of the function, the query would look like this: SELECT DateName(mm,DataEntrada) as DataEntrada,…
-
3
votes2
answers82
viewsA: SQL Updating Wrong Value
Run the following query: UPDATE CPSCli SET FimValidPre = DATEADD(s, -1, DATEADD(mm, DATEDIFF(m, 0, FimValidPre) + 1, 0)) Explaining the operation of the query: DATEDIFF(m, 0, FimValidPre) DATEDIFF:…
-
4
votes1
answer88
viewsA: Limit records by number of repetitions
Try adjusting your query to filter after grouping the data with the clause Having: SELECT COUNT(1) AS QTD, Nome, Cpf FROM Funcionarios GROUP BY Nome, Cpf HAVING COUNT(1) >= 2…
sqlanswered Pedro Paulo 3,651 -
0
votes2
answers62
viewsA: Search images across subdirectories
You can return one Ienumerable with the directories of your files. This method I am passing you will look for in the root directory and in the subdirectories from the informed path. First parameter…
c#answered Pedro Paulo 3,651 -
3
votes2
answers672
viewsA: How to open the notepad with contents inside without saving?
To open the Notepad and write some text on it you need to run the process of Notepad and then use some Windows features. First import these two methods into your class: using…
c#answered Pedro Paulo 3,651 -
2
votes1
answer975
viewsA: Error while saving file - Already being used by another process
Try using your Streamwriter within a block using to have Dispose done after using the resource. using (StreamWriter escreverentrada = new StreamWriter(@"escreveentrada.txt", true)) { string valor =…
-
1
votes1
answer647
viewsA: How to add SQL Server primary key?
Run the following table change code. ALTER TABLE NOME_DA_TABELA ADD PRIMARY KEY (NOME_DO_CAMPO)
-
4
votes3
answers1275
viewsA: Changing pictures from a Picturebox C# - Windows Form Aplication
You can take the files from the folder and pass the next button as follows. I left a method in case you want to make a back button too. Add a variable to save the index of the image being shown.…
-
0
votes3
answers160
viewsA: Use string to reference variable
You can try this way: public void execSQL(string sql) { //A variável "valor" vai estar com o valor da variável que você passou como parâmetro. //O objeto "classe" deve ser o objeto que possui a sua…
-
0
votes1
answer52
viewsA: As popular dropdwonlist with datetime AM value and another dropdwonlist with PM C#
I made a code snippet with the idea to be used in your context: //Variável que representa uma data e um horário qualquer DateTime data = new DateTime(2010, 10, 10, 3, 00, 00); //Variável para…
-
0
votes1
answer809
viewsA: ASP.NET Core - Search for GET requests
You need to create a controller for your domain object: Apiversion = Version of your API Route = Route to access your controller by url Httpget = You define that your method will be the GET verb of…
-
1
votes1
answer438
viewsA: Error passing parameter through Getasync method
The problem is that you are passing your parameter incorrectly, if you are using C# version 6 or higher you can pass parameter using string Interpolation: HttpResponseMessage response = await…
-
0
votes1
answer94
viewsA: Pass a property to a Label on Xamarin
If you are using the MVVM model, add a property to your Viewmodel (remembering that your Viewmodel should implement the interface Inotifypropertychanged, I’ll leave an example). using…
-
2
votes3
answers222
viewsA: Decimal problems in the SQL string
What is happening is that the system has a globalization configuration, by default is being used the culture of your server that is probably en-BR (Portuguese-Brazil). What you can do is change this…
-
1
votes2
answers161
viewsA: Change the "Web Reference URL" of the Webservice added by add web
Web.config Inside the tag add your new url to the Web Reference. <appSettings> <add key="urlWebService" value="http://www.google.com" /> </appSettings> When you instantiate the…
-
1
votes2
answers94
viewsA: doubt with Linq to sql
I will modify the query to stay in the structure of LINQ with Lambda Expression beauty? Try using the following code snippet (I did based on your example): //Inner Join entre a tabela de Venda e…
-
0
votes1
answer139
viewsA: Grouping in LINQ with multiple entity records
Try grouping only by the specific fields (the fields that will be used in your clause select) instead of trying to group by the whole entity. Do the following: group new { ms.EventoID,…
-
0
votes1
answer97
viewsA: Image upload using Picturebox - windows Forms
The problem is occurring because you have a different amount of columns and values in Insert. Note that you have 18 columns, but only 17 values. insert into CadOnibusUser ( F_Cod, Id_UserOnibus,…
-
1
votes1
answer447
viewsA: Side Menu - Xamarin Forms
I’ll leave some code snippets for you to try replicating in your application, in case you have any questions I’m available. --------- Masterdetailview ------------ View Note: Change the code…
xamarin-formsanswered Pedro Paulo 3,651 -
0
votes1
answer84
viewsA: How to bring all items that have no reference with a given table [SQL]
You can make a Linq with left Join, so it will bring people who are not yet users of your system. The code snippet would look like this: pessoaDomain.GroupJoin(usuarioDomain, pessoa => pessoa.Id,…
-
1
votes1
answer724
viewsA: Convert Time 24 hours to 00 hours
If you take your Datetime variable and make a Tostring on it passing the hour format with the letter "H" uppercase, it will already appear in the 00-hour format. Uppercase "HH" format appears in…
-
0
votes1
answer179
viewsA: Problem when viewing data from a grid within code Behind
From what I understand you need only show the ID and the Name on your gridview. You can change to Boundfield, which will show you the text and when you try to access the Behind code it will work…
-
1
votes3
answers282
viewsA: How can I do "Inner Join"
I’ll give you an example using Linq with Lambda Expression. database.equipamento.Join(database.tipo_indicador, equipamento => equipamento.CAMPOREFERENTEJOIN, tipo_indicador =>…
-
1
votes1
answer118
viewsA: Shorten/Camouflage very large text within a grid
A suggestion for you: In the class you own the description property (Ocidescr) you can add a new property that would be the short description, when the user click on it you would open a modal…
-
0
votes1
answer88
viewsA: Error when searching large amount of data in Entity framework,
It turns out that you are returning a lot of data, using grouping functions (Group By, Sum) and this requires a lot of Entity framework. When working with a lot of data it is recommended to use the…
-
1
votes1
answer58
viewsA: Error that is occurring
From what I can see in your code snippet, you get in your method the parameter int id, but in your code you pass Cod. This makes the parameter not recognized. You didn’t show the Details code, but…
c#answered Pedro Paulo 3,651 -
0
votes1
answer118
viewsA: Error trying to register in C#
Try adding this code snippet in your class that represents the context of the database application: protected override void OnModelCreating(DbModelBuilder modelBuilder) {…
-
1
votes2
answers101
viewsA: Linq equivalent to the t-sql command
I made an example algorithm for you to apply, but you will need to replace it with your tables. I created a class that represents the data that will be returned by the query: public class Soma {…
-
1
votes1
answer227
viewsA: ASP.Net and C# - Reducing dropdown options according to current date
From what I understand of your problem, you want me to add 1 month after the current one when the day is less than 11 and add 2 months when the day is longer than 11. I’ve done a code snippet for…