Posts by João Martins • 5,597 points
279 posts
-
0
votes3
answers204
viewsA: Update app.config or web.config via code
You can always create a Settings, where you can then update the values simply: using MyApp.Properties; // por propriedade Settings.Default.var1 = "teste"; Settings.Default.var2 = 10;…
c#answered João Martins 5,597 -
1
votes1
answer179
viewsA: Transform Sql command into LAMBDA
Assuming we have this sampling information: List<Aeronave> aeronaves = new List<Aeronave>() { new Aeronave() { cdAeronave = "001", dsAeronave = "001", idAeronave = 1 }, new Aeronave() {…
-
1
votes1
answer210
viewsA: Download the VARBINARY image
Implement the following method: private static Image GetImage() { using (SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-7FBA9V8\SQLEXPRESS;Initial Catalog=VALIDACAO;Integrated…
-
2
votes1
answer235
viewsA: C# - Subselect in Lambda and Linq
Maybe this way? var leftJoin = (from tbe in tb_Empresa join tce in tb_Consulta_Empresa on tbe.cd_empresa equals tce.cd_empresa into tbetce from tce in tbetce.DefaultIfEmpty() where tce.cd_consulta…
-
2
votes7
answers1103
viewsA: Remove part of string until nth occurrence of a character
Implement the following method to generalize the behavior you want: private string DevolvePartes(string strTexto, int intPartes, string strSeparador) { return string.Join(strSeparador,…
-
2
votes2
answers120
viewsA: Limit INNER JOIN query to only one ID
Try it this way (if I understand what you want): SELECT E.image , E.status AS status_enquete , E.id AS id_enquete , E.title AS titulo_enquete , P.id AS id_pergunta , P.title AS titulo_pergunta FROM…
sqlanswered João Martins 5,597 -
2
votes3
answers98
viewsA: Sort select displaying something at the end after sorting
Something should not be right in your definition of tables, because in Tabela 2 must be the column Indice, otherwise linking with each other the result would not be correct. Assuming that the Tabela…
-
1
votes1
answer3679
viewsA: Conversion of string " to integer type is not valid
The error must be happening because the text that is in boxvenda.Text is empty and cannot be converted to a valid number. I think this way you can avoid the error, and at the same time greatly…
vb.netanswered João Martins 5,597 -
0
votes3
answers133
viewsA: SUM of one table minus the SUM of another in the same field
The query below allows you to show the results you want: SELECT A.docnum AS doc , A.clienteid AS cliente , A.valor AS valordocumento , A.valor - ISNULL(B.valor, 0) AS valoremdebito FROM tabelaA A…
-
0
votes1
answer63
viewsA: Values of the IN clause as a parameter for in a column subselect
Maybe so? SELECT DISTINCT 'Atendimentos' AS Tipo , TO_CHAR(A.DT_ATENDIMENTO, 'mm/yyyy') AS Competencia , PRE.CD_PRESTADOR , SE.CD_SETOR , SE.NM_SETOR , NVL(X.Contador, 0) AS Total FROM ATENDIME A…
-
2
votes2
answers99
viewsA: Validation with Dataannotation
In your case the MaxLengthAttribute will not work because, as the error itself indicates, it only applies to types String or array of Byte. There are two ways around the problem: 1. Instead of using…
c#answered João Martins 5,597 -
0
votes2
answers88
viewsA: I want to leave a string with Zero value
Implement the following method: private void StringToDouble(ref string text) { if (!text.Contains(",")) text += ",00"; else { string strCasasDecimais = text.Substring(text.IndexOf(",") +…
c#answered João Martins 5,597 -
0
votes2
answers158
viewsA: Incorrect formatting of string to decimal during Excel import
Maybe changing the formatting in the column itself (I named it "Billing"): MyDataGridView.Columns["Faturamento"].ValueType = typeof(decimal);…
-
0
votes1
answer71
viewsA: Formatting textbox
The problem will most likely be that the variable numtel be the type String, which prevents formatting from being applied. The solution is to convert to whole and then make the conversion, more or…
vb.netanswered João Martins 5,597 -
0
votes2
answers79
viewsA: Detecting if a Setter of a property has been called
It will have to implement, obligatorily, in the Setter the evocation of a method for what you want. As far as I know there is no way to automatically figure out if a value has been changed without…
-
3
votes2
answers72
viewsA: How to include dates even if there is no data
Try it this way: SELECT V.DataV , IFNULL(COUNT(IF(axlNumber = 2, 1, NULL)), 0) AS eixos2 , IFNULL(COUNT(IF(axlNumber = 3, 1, NULL)), 0) AS eixos3 , IFNULL(COUNT(IF(axlNumber = 4, 1, NULL)), 0) AS…
-
4
votes1
answer456
viewsA: Using C# Threads for the First Time
If you really have to threads, then do the following: private Thread thread; private void btn_ObtemClientes_Click(object sender, EventArgs e) { thread = new Thread(() => {…
-
1
votes2
answers294
viewsA: Take field letters in MYSQL
Try creating the following function: DROP FUNCTION IF EXISTS alphanum; DELIMITER | CREATE FUNCTION alphanum( str CHAR(255) ) RETURNS CHAR(255) DETERMINISTIC BEGIN DECLARE i, len SMALLINT DEFAULT 1;…
-
1
votes1
answer59
viewsA: COUNT in multiple mysql tables
I think this solves your problem: Dim reader As MySqlDataReader Dim CmdSalvarItens As MySqlCommand Dim Query As String Dim resultquery As String Dim strCPF As String Dim strMovimentos As String Dim…
-
0
votes2
answers108
viewsA: How to order a select 1 to 255?
Since they’re Ips of the type IPV4 (numbers only), you can remove the point '.', do the CAST to number and sort normally around: SELECT IPS FROM ipvalidos WHERE REDE = '{$rede}' ORDER BY…
-
1
votes1
answer54
viewsA: Error during Page Deletion - Xamarin
Try changing the XAML of CarouselView to the following: <CarouselView x:Name="slideTopo" ItemsSource="{Binding .}"> <CarouselView.ItemTemplate> <DataTemplate> <Label…
-
1
votes1
answer75
viewsA: Count the number of characters of a value within a column of a Datagridview [C#]
The answer is relatively easy with LINQ: var linhas = myDataGridView.Rows.Cast<DataGridViewRow>().Select(r => Convert.ToString(r.Cells["mensagem"].Value)); double somaLinhas = linhas.Sum(r…
-
4
votes1
answer364
viewsA: How to calculate the discount average in Mysql
It’ll be something like this: SELECT ID_PROD , AVG(desconto) AS media FROM object GROUP BY ID_PROD
mysqlanswered João Martins 5,597 -
1
votes2
answers343
viewsA: Sql for plot counting
The COUNT you’re using will always return 1, be it COUNT(1) or COUNT(0) or even COUNT(1000), which is why it is not delivering the expected results. The solution is to use the SUM, to be added 1…
mysqlanswered João Martins 5,597 -
2
votes2
answers74
viewsA: Typing
You must use the property Date: var dateAndTime = DateTime.Now; var date = dateAndTime.Date; The variable date will contain the date, part of the time will be with the value 00:00:00. More…
-
1
votes1
answer60
viewsA: Calling C# method in C
Check the following conditions: 1. Estate Register for COM interop in the separator Build of the project 2. Information of COM Visible and unique GUID in class AssemblyInfo.cs which is in Properties…
-
1
votes1
answer191
viewsA: Rotate image around the center itself
Try implementing the following method: public static Bitmap RotateImageN(Bitmap b, float angle) { //Create a new empty bitmap to hold rotated image. Bitmap returnBitmap = new Bitmap(b.Width,…
-
0
votes2
answers70
viewsA: SQL + Medium Query
Try it this way: SELECT X.Descricao , AVG(X.calculo_diff) AS Media FROM ( SELECT Descricao , DataHoraTerno , @linha := TIME_FORMAT(TIMEDIFF(@DataHoraTerno, DataHoraTerno), '%H%i') AS calculo_diff ,…
-
4
votes2
answers6656
viewsA: Help with SQL error 1064
There are 3 problems with the commands you indicated in your question: 1. Two dots instead of a semicolon on: use bancoteste: 2. Keychain ({) instead of parentheses (() in: create TABLE login{nome…
-
2
votes2
answers211
viewsA: How can I treat Interops with an Assemblyresolve for a Class Library (DLL) project
The process is exactly the same, but as in a Class Library has no input method (Main), will have to put the Assembly Resolve in the class constructor (complete example): using System; using…
.netanswered João Martins 5,597 -
2
votes1
answer44
viewsA: Play list in an array
If the results are of the type string can do as follows: string[] doc = xDoc.Select(r => $"{r.OutrasInformacoes}|{r.Numero}|{r.Codigo}").ToArray();; string[] doc1 = xDoc1.ToArray(); The array doc…
c#answered João Martins 5,597 -
1
votes1
answer106
viewsA: Count repetition amount of an item
If you want to have items that have more than one register then you will have to change the COUNT: SELECT COUNT(1) AS QTDE , CODIGO , DESCRICAO , UNIDADE FROM TB_ITEM GROUP BY CODIGO , DESCRICAO ,…
-
0
votes3
answers72
viewsA: Code reduction in sql query
Maybe in this way (I think I got the point right): SELECT F.* FROM ferramenta F LEFT JOIN estoque E ON E.ferramenta_codigo = F.codigo WHERE F.obrigatorio = 1 AND ( E.empresa_codigo <> 2 OR…
-
2
votes1
answer241
viewsA: How to select by comparing two columns
I think the solution will be something like this: SELECT X.COLUNA_A , TMP.COLUNA_B FROM ##TBL_TEMP TMP INNER JOIN ( SELECT COLUNA_A , COUNT(DISTINCT(COLUNA_B)) AS CONTADOR FROM ##TBL_TEMP GROUP BY…
sql-serveranswered João Martins 5,597 -
1
votes1
answer56
viewsA: SQL query for foreign key null fields
Maybe then you can solve your problem: SELECT ISE.id , ISE.data , Id = ISNULL(MO.id, PE.id) , Descricao = (CASE WHEN MO.id IS NOT NULL THEN MO.descricao ELSE PE.nome END) , Valor = (CASE WHEN MO.id…
sqlanswered João Martins 5,597 -
1
votes1
answer185
viewsA: PIVOT query in Mysql
Maybe so? SELECT ftd.DateAndTime AS dt , SUM(CASE WHEN ttd.TagIndex = 9 THEN ftd.Val ELSE 0 END) AS '9' , SUM(CASE WHEN ttd.TagIndex = 8 THEN ftd.Val ELSE 0 END) AS '8' , SUM(CASE WHEN ttd.TagIndex…
-
0
votes1
answer37
viewsA: SQL problem
Experiment as follows: SELECT c.numCad , c.nomFun , qtDep.dependentes FROM colaboradores c LEFT JOIN ( SELECT numCad , COUNT(1) AS dependentes FROM dependentes GROUP BY numCad HAVING COUNT(1) > 1…
sqlanswered João Martins 5,597 -
2
votes1
answer41
viewsA: How to implement progressiBar in FTP download
In your case you can do as follows: private int GetFileSize(string url, NetworkCredential nc) { // Query size of the file to be downloaded WebRequest sizeRequest = WebRequest.Create(url);…
c#answered João Martins 5,597 -
0
votes2
answers1444
viewsA: Convert Integer to Decimal in Oracle
You can always use the function TO_CHAR: SELECT TO_CHAR(NVL(SUM(ve.vl_vencimento), 0), '999999D99') Valor_Total_da_Ordem FROM ordem_compra
-
1
votes3
answers1854
viewsA: SQL query to know the sales of a period (year), dividing by month and showing the total of each month and year
To Stored Procedure below follows the following steps: Get every year between two dates and put in temporary table (#TmpAnos) Creates a temporary table where the orderly and processed records will…
-
0
votes1
answer697
viewsA: How to perform a search disregarding Firebird special characters in the WHERE Clause
I’m not familiar with Firebird, so I’m not sure if this solution is viable, but it’s worth: CREATE VIEW VWORDEMPRODUCAO (CODEMPRESA) AS SELECT F002 AS CODEMPRESA FROM MFT05O020 WHERE (CAST(F020 AS…
-
1
votes2
answers68
viewsA: Show how much it costs in total
I cleaned up your code a little bit and optimised some points: namespace WindowsFormsApp4 { public partial class FourCustomController : UserControl { float somaTotal = 15; public…
-
0
votes1
answer77
viewsA: Trigger insert and change data
Try it this way: DROP TRIGGER IF EXISTS trg_entradarm; DELIMITER // CREATE DEFINER=root@localhost TRIGGER bailledados.trg_entradarm AFTER INSERT ON prodvdmat FOR EACH ROW BEGIN SET @existe = (…
-
0
votes1
answer63
viewsA: Select COUNT > 10K in C# and SQL
You can always do it this way: SELECT * FROM ( SELECT * , ROW_NUMBER() OVER(ORDER BY Registo ASC) AS Linha FROM Tabela) X WHERE Linha <= 10000 In the ORDER BY Registo ASC we must replace the…
-
1
votes1
answer130
viewsA: How to convert and save Datagridview data to Mysql database
Create a method that allows you to convert string for double: private double ConverteStringParaDouble(object valor) { double dblValor = 0; string strValor = Convert.ToString(valor); strValor =…
-
1
votes1
answer133
viewsA: When Maximize a wpf page c# it overwrites the windows taskbar
Try the following: MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth; Basically we’re limiting the maximum height and width of the…
-
1
votes2
answers378
viewsA: Get the invoiced amount from the previous month
This way you can have the amount billed from the previous month but also the amount of users and the previous month, if necessary: SELECT U.MUNICIPIO , U1.MES , U1.QTDUSUARIOS , U1.VALORFATURADO ,…
-
2
votes1
answer179
viewsA: Automatic filling of Textbox
You can always use the event onblur and then complement the @email with. client-side: <input type="text" id="email" onblur="addEmailSufix()"> On the client’s side: <script> function…
asp.net-mvcanswered João Martins 5,597 -
1
votes1
answer291
viewsA: How to load data into a combobox whenever registering new values
You can do something like this: // colocar a ConnectionString como variável global ao Form private string connString = "Data Source=LAPTOP-EVMCT3AM;Initial Catalog=dbESCOLA;Integrated…
-
2
votes1
answer97
viewsA: Return the smallest value using the Entity Framework
Experiment as follows: var produtos = (from prod in contexto.Produtos join emb in contexto.ProdutoEmbalagems on prod.Id equals emb.IdProduto where prod.IdEstabelecimento == idEstabelecimento select…