Posts by Rovann Linhalis • 14,881 points
567 posts
-
1
votes2
answers657
viewsA: Save Image in VARBINARY with C# ASP.NET
On your model, you need an Iformfile type property: public class MyModel { public IFormFile Arquivo {get;set;} } In your object, or POCO class, you need a byte property[]: public class MyObject {…
-
2
votes1
answer242
viewsA: Error at agupar Mysql subquery
Only filter the subquery by the month of the main query: SELECT MONTH(P.data_venda), SUM(P.vlr_tot_liquido) AS Faturamento, SUM(P.custo_total) AS Custos, SUM(P.vlr_tot_liquido) - SUM(P.custo_total)…
-
1
votes2
answers1487
viewsA: Save Image in Database with C#
On your model, you need a property of type IFormFile: public class MyModel { public IFormFile Arquivo {get;set;} } In your object, or POCO class, you need a property of type byte[]: public class…
-
1
votes1
answer57
viewsA: Add values from a table
Following your logic, to count how many won_actions user had in the current month: SELECT r.id, r.username, count(w.id) as total FROM won_auctions w INNER JOIN registration r on r.id = w.userid…
-
9
votes1
answer6033
viewsA: How to validate a CRM Medical Record?
Validation per checker digit, similar to CPF, is not possible. As already mentioned in the comments, CRM is only a sequential number. Some time ago, I had made the query through the portal. I…
-
1
votes1
answer576
viewsA: Load image from project
You can convert it to a string on base 64 and put it into src of the image: I’ll consider that you have a System.Drawing.Image. First, convert to a byte array (byte[]): /// <summary> ///…
-
1
votes1
answer873
viewsA: PDF generated with iTextSharp adding image gets bad quality
In your image resize method, you are using var image = bitmap.GetThumbnailImage(width, heigth, null, new System.IntPtr(0)); return new Bitmap(image); This method returns a thumbnail of the image…
-
3
votes1
answer296
viewsA: Clear the console every 30s
As the console runs in the Main method, which in turn is a static method, I believe the output is to use another Thread. In the code below, I create a Thread "t" that will wait 10 seconds, and then…
c#answered Rovann Linhalis 14,881 -
4
votes2
answers1593
viewsA: How to insert sequence in non-automated field
Try it like this: INSERT INTO contatos (cod, nome) SELECT (coalesce((SELECT MAX(cod) FROM contatos),0)+ row_number() OVER ()), nome FROM fornecedores; I put the coalesce, in case the table contatos…
-
4
votes1
answer37
viewsA: Other account data with facebook authentication
I was able to solve what I needed. The code you were using in the question is not required. It is sufficient that, in the AccountController in action ExternalLoginCallback you pass the values it…
-
1
votes1
answer1060
viewsA: How to add columns from different tables?
For the error message, you are only asking for an alias for the derived table: SELECT SUM(x.Total_P + x.Total_A) AS Total FROM (SELECT Pi.IdItem, SUM(Pi.Quantidade * Pi.ValorUnit) AS Total_P, 0 AS…
-
0
votes1
answer87
viewsA: Dynamically remove components in C#
Create a list and store the ones you created: List<PictureBox> pbs = new List<PictureBox>(); public void drawimg(int x, int y, bool clear_) { PictureBox marker = new PictureBox(); if…
-
4
votes1
answer37
viewsQ: Other account data with facebook authentication
I am implementing authentication by facebook and wanted to, when entering the application with the account data, save also full name, photo, among other data. Searching, I got the following code:…
-
2
votes2
answers171
viewsA: Delete and relocate index
Responding to your comment in Maniero’s reply: Suppose you have multiple records: n 1 2 3 4 5 6 You will delete n 3. After deletion, simply perform a command: update tabela set n = n-1 where n >…
-
7
votes2
answers494
viewsA: How to store an array in a string?
Only use the Join string[] y = {"5", "0","0","5","5"}; string x = string.Join("",y); Console.WriteLine(x); Check on . Netfiddle: https://dotnetfiddle.net/4exn35 Documentation:…
c#answered Rovann Linhalis 14,881 -
2
votes3
answers437
viewsA: Visual Studio INSERT command error
You define SET IDENTITY_INSERT as ON but does not pass the cod_Func in charge Insert. According to the documentation: https://msdn.microsoft.com/pt-br/library/ms188059%28v=sql.120%29.aspx?…
-
0
votes2
answers840
viewsA: Update in a column using more than one return
Whereas in the product table there is only one value for each customer and product, and you need to upgrade product 2, subtracting the product value if it is lower. I think you can simplify this…
-
1
votes1
answer1147
viewsA: SELECT in a parent table where ALL children are in the same situation - Mariadb/Mysql
First you select everyone who has children aged = 14 (for example), and then remove everyone who has a child other than 14. Follows the code: SELECT DISTINCT p.pai_id, p.pai_nome FROM pai p INNER…
-
0
votes2
answers61
viewsA: Static class system settings in the Entity Framework
I could not find a solution to the proposed problem. I solved by creating a configuration class normally, and declaring a static object in the application. Every configuration I need, I take this…
-
3
votes1
answer226
viewsA: Doubt - Winforms on the subject on the second screen
I made a code to adjust the label font automatically by the size of the Form, see if it works and then comment on the code explaining everything Timer tSize = new Timer() { Interval = 300, Enabled =…
-
2
votes1
answer515
viewsA: Select com when e case
The column alias will not work in Where, you have to put the expression also in the syntax. select F.nu_ine INE, to_char(D.dt_ficha, 'YYYYMM') as CMP, I.co_cbo_2002 CBO, (CASE WHEN (B.tp_atend = 1…
-
3
votes1
answer235
viewsA: Dotnetzip zipping file without folder directory
You just need to enter a second parameter in the method AddFile see: public static void Zipar(FileInfo file) { using (ZipFile zip = new ZipFile()) { zip.Password = "******";…
-
0
votes1
answer148
viewsA: Picturebox Dinâmico
Whereas you are using winforms and your code is in the form itself: Place a Flowlayoutpanel wherever the photos appear, and then change your Reader loop: while (reader.Read()) { fotoArray =…
c#answered Rovann Linhalis 14,881 -
2
votes1
answer1302
viewsA: Datetime UTC Opening hours NF-e
According to the taxpayer’s guidance manual, Sefaz does adopt daylight saving time. Therefore, you should inform the zone -03:00 when you are not in daylight saving time and -02:00 when you are…
-
0
votes1
answer32
viewsA: Error in passing C#parameters
Your t.Codigo must be of the string type, and the return of the method is of the DateTime. you can try to do so: t.Codigo = GetValorDateTime(tabela, i, "DataDeContrato",…
c#answered Rovann Linhalis 14,881 -
2
votes1
answer32
viewsA: MYSQL and condition
John, as Leonardo said, you put on Where the condition of the record having two values at the same time, it will always return empty. Just take one of the conditions, or change the operator.…
-
1
votes2
answers1722
viewsA: Select and delete duplicate records by last update date?
I made the following query: delete t.* from configuracoes t inner join (select c.nome, c.valor, c.date_add, c.date_upd from configuracoes c where c.date_upd = (select max(x.date_upd) from…
-
2
votes2
answers65
viewsA: Replace in undefined texts
I suggested you replace it with the variables. I imagine you have a list of all the variables and which id_event should be searched when it is that variable, so you can assemble a Dictionary:…
c#answered Rovann Linhalis 14,881 -
1
votes2
answers569
viewsA: How to delete duplicated lines sequentially
I arrived at the following result, where I selected all the records that should be deleted. with tabela as ( Select ROW_NUMBER() OVER(ORDER BY DataHora ASC) as linha, p.Cliente, p.Status, p.DataHora…
sqlanswered Rovann Linhalis 14,881 -
0
votes2
answers153
viewsA: SQL - Insert that receives calculated values from other columns of other tables
With Sub Select: INSERT INTO VENDAS (produto,quantidade,valor_venda) values (::produto,::quantidade,((select valor_unitario from produtos where codigo = ::produto)*::quantidade)); where ::produto is…
postgresqlanswered Rovann Linhalis 14,881 -
8
votes3
answers3861
viewsA: How to replace the comma
You can do it like this: double x = 2.32; string texto = x.ToString("N", CultureInfo.CreateSpecificCulture("en-US")); Reference: https://msdn.microsoft.com/en-us/library/d8ztz0sa(v=vs.110). aspx…
-
2
votes1
answer40
viewsA: Open.CV Error Save File
It may be that the library can interpret the / in the file path, but the normal is \. You can try: faceRecognizer.Save("C:\\Temp"); or…
-
1
votes1
answer292
viewsA: Calculate circular Progressbar time C# (Windows Forms)
Simple, set the range of the timer for 1 second. Assign the value of progressBar as [minutos escolhido pelo usuário] * 60 At each tick of timer, decreases a value of progressBar…
-
1
votes2
answers490
viewsA: Xamarin (Visual Studio) x POSTGRESQL
If you want to work with Postgresql directly in the mobile application, the answer is no. You have no way to install Postgresql on Android, iOS or winPhone. For this you have the Sqlite. If you want…
-
5
votes1
answer3058
viewsA: SQL distinct with sum
I think we just need the group by in the first query, and you can’t use the ID, of course, if not, it won’t add select t.nomeuc as "Nome UC", t.tipoturno as "Tipo Turno", SUM(a.num_presencas) as…
-
0
votes2
answers79
viewsA: join two tables with date condition
Make a left Outer Join by setting the conditions in the Join, and use the coalition for products that have no corresponding records in the table2: Select p.cod_barras, p.descricao,…
-
1
votes4
answers70
viewsA: How to return the sum of the business value column, month by month, based on the starting data_column?
Separating by the years, but without displaying them: Select MONTHNAME(DATE_FORMAT(data_inicio,'%Y-%m-01')) as mes, sum(valor_negocio) from negocio group by DATE_FORMAT(data_inicio,'%Y-%m-01') order…
-
3
votes2
answers200
viewsA: Is there any way to implement an interface in a class of a DLL that I can only read?
And if you created a class MeuComunicador just to implement the interface, would solve your problem? Example: using System; public class Program { public static void Main() { MinhaClasse obj = new…
-
0
votes1
answer87
viewsA: Catch Startaddress with the Thread Module name of an external program
I do not know if it is exactly the information that appears in Processexplorer, but the process has the modules, the thread does not. To get the module names as you ask the question, you can do so:…
-
1
votes2
answers1721
viewsA: How do I know if the database connection was successful?
You have not specified what you are using to connect to Mysql. Normally, the MySql.Data.MySqlClient, but it is also possible to do with ODBC driver (System.Data.Odbc). In both cases, the connection…
-
2
votes3
answers5991
viewsA: Convert number to string to two decimal places
Just Convert to decimal, and then use Tostring by specifying the format. using System; using System.Globalization; public class Program { public static void Main() { string numero = "12,126456";…
-
0
votes2
answers275
viewsA: Relationship problem in the Mother Table (Inheritance) in Postgresql
Reading the documentation: https://www.postgresql.org/docs/current/static/ddl-inherit.html#DDL-INHERIT-CAVEATS I found that: Other types of constraints (single key, primary key and foreign key…
-
1
votes1
answer432
viewsA: Play value from a grid that is in form to another grid in another form C# windows form
Recommend changing the event CellContentClick for CellMouseDoubleClick for the user to make two clicks to select the desired record. The Reference Error may be happening because Cell’s . Value may…
-
0
votes2
answers4406
viewsA: Insert into with select
just change the select, and do not use * INSERT INTO your_table SELECT '1' as novo_id, '2' as nova_fk, t.outros_campos FROM temp_table t;…
sqlanswered Rovann Linhalis 14,881 -
0
votes1
answer64
viewsA: Socket Whitelist IP accepted connection C#
Only create a List with the allowed ips, and when the connection comes check if the list contains the ip you connected: private void teste(Socket ClientSocket) { List<string> whiteList = new…
-
0
votes2
answers710
viewsA: Help with Join in two different selects
I did not go into your model, to better understand what you need, paying attention only to the need to relate two distinct selects. One option is to use temporary tables: with tabelaX as ( select…
-
2
votes2
answers259
viewsA: Single auto increment on all DB tables
In postgres, you could use inheritance between tables: Tabela "Transacoes" id | data Tabela "Vendas" que herda "Transacoes" cliente Tabela "Compras" que herda "Transacoes" fornecedor But in Mysql I…
-
1
votes2
answers61
viewsQ: Static class system settings in the Entity Framework
I am trying to create settings for a system. I thought of a class similar to the example: Class: public static class Configuracoes { [DisplayName("Casas Decimais")] [Description("Informa o número de…
-
7
votes2
answers170
viewsA: Doubt - Savechanges does not work, only returns 0
You do not need to select an anonymous object or a different class to then perform an update. Just run select, change the field, and then update. using (var db = new Entities()) { var result = db.…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer245
viewsA: Exchange variables from selected word documents
with the short snippet you have placed, and whereas the checkedlistbox item is the name of the file you want to change, make an iteration between the checked items: foreach (string arquivo in…
c#answered Rovann Linhalis 14,881