Posts by João Martins • 5,597 points
279 posts
-
2
votes2
answers173
viewsA: sql record in tables and return the table name
Try it this way (there are others): SELECT ME.* , CASE WHEN PA.idMembro IS NOT NULL THEN 'pastores' ELSE ( CASE WHEN RD.idLider IS NOT NULL THEN 'redes' ELSE ( CASE WHEN RE.idLider IS NOT NULL THEN…
-
1
votes3
answers89
viewsA: Add values to total - SQL
From what I understand you want to add the others_price after the sum, so try it this way: SELECT TPP2.sub_total + TPP.others_price FROM tbl_purchase_product TPP INNER JOIN ( SELECT SUM(sub_total)…
sqlanswered João Martins 5,597 -
0
votes2
answers49
viewsA: How to simplify this Consultation?
Another way to structure consultation (and I think the most performant): SELECT ME.* FROM membros ME LEFT JOIN pastores PA ON PA.idMembro = ME.idMembro LEFT JOIN redes RD ON RD.idResponsavel =…
-
2
votes1
answer68
viewsA: Perform table grouping with two parameters
Without knowing the whole structure of the table I would say it will be something like this: SELECT TO_CHAR(DATA, 'YYYY-MM') AS MES , SUM(QTDUSUARIOS) AS QTDUSUARIOS , MUNICIPIO , SUM(VALORFATURADO)…
-
3
votes1
answer421
viewsA: Open file from a network folder
The problem may be in the way the password is being built in the SecureString. Try creating the following method (do not forget the using System.Security): using System.Security; public static…
c#answered João Martins 5,597 -
3
votes2
answers213
viewsA: How to filter only the last day of each month?
From SQL 2012 should be able to use EOMONTH: SELECT E8_FILIAL , E8_AGENCIA , E8_CONTA , E8_DTSALAT , E8_SALATUA FROM SE8010 AS SE8 WHERE E8_CONTA IN ('84361','22700') AND D_E_L_E_T_ <> '*' AND…
-
2
votes2
answers650
viewsA: Save file with openFileDialog
Try it this way: using System.IO; private void btAnexarArquivo_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog() { Filter = "Arquivo PDF|*.pdf", Title =…
-
1
votes1
answer235
viewsA: Pick up day of the week in a select
Not knowing well the objective and structure of the table, considering that the column campo.tabela is a whole and the beginning of the week begins at the Domingo, may consult the Commission as…
-
0
votes1
answer284
viewsA: "C#" - The parameterized @image bi query expects the @image parameter that was not provided!
Try it this way: bool novaFoto = false; byte [] foto; Bitmap bmp; private void Button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { bmp = new…
c#answered João Martins 5,597 -
1
votes1
answer1512
viewsA: SQL use of LEFT JOIN with OR
Depending on the purpose, the consultation may have LEFT JOIN or INNER JOIN. If what you want is to get the results by directly linking the 3 tables, where a table record cli exists obligatorily in…
-
0
votes4
answers177
viewsA: Count(*) returning null
If we assume that your table has a primary key (or column with unique values), you can do something like: SELECT ISNULL(X.CONTADOR, 0) AS CONTADOR, UIC.* FROM USER_IND_COLUMNS UIC LEFT JOIN ( SELECT…
-
1
votes1
answer1450
viewsA: Problem with accents, C# App Console
Experiment as follows: using System.Text; public void LereGravar() { Console.WriteLine($"{DateTime.Now.ToString()} - Processamento Iniciado, Lendo Arquivo"); var files =…
-
1
votes1
answer380
viewsA: Read Html from a web page by running an application in wpf c#
Add to your Form a control of the type WebBrowser (or create in code), where later, in code, you must invoke the method Navigate to navigate to the URL you want: WebBrowser webBrowser1 = new…
c#answered João Martins 5,597 -
1
votes2
answers126
viewsA: Googlemaps + c#
Try it this way: var client = new RestClient("https://maps.googleapis.com/"); var request = new RestRequest(Method.GET); request.Resource = "maps/api/geocode/json?address={cep}&key={key}";…
-
0
votes1
answer73
viewsA: Single-line save in DB, the result of the PHP variable (WHILE/LOOP) of a MYSQL Query
Changing your code to the following solves the problem? while($reg = mysqli_fetch_object($query_sku )) $variable .= " ".$reg->column_name; In the variable $variable is the concatenation of all…
-
3
votes1
answer66
viewsA: Assistance with SQL
I think something like that solves your problem: SELECT X.K803 , X.CODREPR , X.PERIODO , X2.META , X2.DESAFIO FROM XXX X INNER JOIN ( SELECT K803 , PERIODO , AVG(META) AS META , AVG(DESAFIO) AS…
sqlanswered João Martins 5,597 -
2
votes2
answers66
viewsA: Doubt about filtering a Query in SQL
I think that in this way you will be able to achieve what you want: SELECT C.IDCLIENTE , C.NOME , C.SEXO , E.BAIRRO , T.TIPO , T.NUMERO FROM CLIENTE C INNER JOIN ENDERECO E ON C.IDCLIENTE =…
sqlanswered João Martins 5,597 -
1
votes2
answers85
viewsA: Low Performance when viewing Datatable C# - Plan Coded Ui Test
Here’s another way to address the problem: var rowsX = dtX.Rows.Cast<DataRow>().Select(r => r[1].ToString().Trim()); var rowsY = dtY.Rows.Cast<DataRow>().Where(r => r[0].ToString()…
c#answered João Martins 5,597 -
1
votes2
answers44
viewsA: Inserting data from a datagridview c# in another datagridview giving 2 clicks
Can’t add more than one product because each time it evokes the event of DoubleClick cell is creating a new instance of the object produtoColecao. This way you should already get: ProdutoColecao…
c#answered João Martins 5,597 -
2
votes2
answers351
viewsA: Sum values from a column in the database via date filter
Why not add a MySqlParameter at the MySqlCommand passing the value of the date? string query = "SELECT IFNULL(SUM(quantidadeVagas), 0) AS Vagas FROM vagas WHERE data = @Data"; using(MySqlConnection…
-
2
votes2
answers284
viewsA: Select with two conditions
You have two choices: SELECT * FROM MinhaTabela WHERE Codigo <> 0 AND Codigo <> 573 Or: SELECT * FROM MinhaTabela WHERE Codigo NOT IN (0, 573)…
mysqlanswered João Martins 5,597 -
10
votes1
answer272
viewsQ: Comparison: CTE vs CURSOR
I do not know if this is a question that many ask, but I have always had it in mind almost always. Usually, when I need to deliver a script corrective to a customer, used only to be executed once, I…
-
1
votes2
answers1911
viewsA: Create Trigger to change record only when modifying a field
The first step is to put a DEFAULT CONSTRAINT in your column Update_data to not have to worry about the INSERT (the date is updated when the registration is added): ALTER TABLE cadastro ADD…
-
1
votes1
answer30
viewsA: Register exact time in the comic
CURDATE() and CURTIME() // ... $sql = "INSERT INTO vendas(preco_venda, data, hora) VALUES"; $sql .= "('$soma_venda', CURDATE(), CURTIME())"; mysqli_query($connect, $sql); // ... In the definition of…
-
0
votes2
answers52
viewsA: BD sales record
If the ID you use in the table vendas is autoincrementable (property AUTO_INCREMENT active) can do as follows: // ... $id_venda = mysqli_insert_id($connect); // ... $sql2 = "INSERT INTO…
-
2
votes2
answers498
viewsA: C# Read TXT file and delete
So you don’t get what you want? string[] caracteresAceites = new string[] { "|0", "|-", "|C", "|I", "| ", "|R", "|D", "|E" }; using (StreamReader leitor = new StreamReader(lerArquivo)) { using…
c#answered João Martins 5,597 -
2
votes2
answers380
viewsA: How to filter records by date using SQL
It’ll be something like this you’re looking for? SELECT TOP 1 * FROM Tabela ORDER BY DT_DATA DESC
-
1
votes3
answers140
viewsA: GROUP BY last registration per month and year how to do?
I think this way you get what you want: SELECT T.* FROM Teste T INNER JOIN ( SELECT Id , MAX(Ano) AS Ano FROM Teste GROUP BY Id) X ON X.Id = T.Id AND X.Ano = T.Ano INNER JOIN ( SELECT Id , Ano ,…
-
2
votes1
answer147
viewsA: Group empty case when sql cells
If you use the GROUP BY I think you get what you want: SELECT adm_fili.cd_filial , fin_lcto.nr_titulo , fin_lcto.sufixo AS parcela , SUM(CASE WHEN fin_lcto.cd_operacao = 3 THEN fin_lcto.vl_operacao…
-
1
votes1
answer185
viewsA: Using Count with select all
You can always try it the way below: SELECT TT.produto , TT.matricula , TT.data , TT.fornecedor , TT.contador FROM tb_teste TT INNER JOIN ( SELECT COUNT(1) AS contador , produto , matricula FROM…
-
1
votes1
answer267
viewsA: Accept only one comma in Textbox c# WPF
It may be better to validate the value when entering text, to avoid incorrect input of characters. For this you must subscribe to the event PreviewTextInput: <TextBox…
-
2
votes1
answer78
viewsA: Concatenation of Records via FOR XML PATH - SQL SERVER
In your query you are placing filters directly on LEFT JOIN when they should be in the clause WHERE: SELECT '; ' + DA.DESCRICAO FROM BD.pre_matricula_doc PDA LEFT JOIN BD.DOCUMENTOS DA ON DA.CODIGO…
-
1
votes1
answer56
viewsA: Rename files from a txt list
The problem is that the TAB. By doing the Split('\t') the text is being divided by TAB instead of removing the TAB and then divide by line break. The solution may replace the line: string[]…
c#answered João Martins 5,597 -
2
votes1
answer210
viewsA: Webmethod to create Sales Document with editing parameters in the document lines
To do this simply edit the last line added to the object DocVenda, still within the cycle foreach (where you are adding lines, one-by-one) and changing the value of the properties you want: // ...…
c#answered João Martins 5,597 -
2
votes2
answers273
viewsA: How to select only people with a first name
Although your question is unclear, I think it will be simple to reach a solution. Let’s assume you have the table below (very basic example): CREATE TABLE Pessoas ( Nome VARCHAR(255) ) Table…
-
0
votes1
answer25
viewsA: View Logging a column in several other columns
Change your query to the following: SELECT AA.id , AA.id_agenda_mod , AA.passageiros , AA.data_saida , AA.hora_saida , AA.km_inicial , AA.data_chegada , AA.hora_chegada , AA.km_final , AA.condutor ,…
-
2
votes1
answer174
viewsA: Save as txt c#
The ideal is to use a FolderBrowserDialog, where the user selects the location wherever the file is created: protected void btn_txt_Click(object sender, EventArgs e) { List<eFC30> Ltxt =…
-
2
votes1
answer43
viewsA: Show help button when text box is selected (C#)
The solution is to create an extension of control TextBox and add the button. Then subscribe to the events GotFocus and LostFocus to show or hide the button: using System.Windows.Forms; namespace…
-
6
votes3
answers475
viewsA: Select months even without records
Try it this way: SELECT YEAR(IFNULL(A.content_path, NOW())) AS anoAtual , MONTHNAME(M.Mes) AS Mes , TIME_FORMAT(SEC_TO_TIME(SUM(IFNULL(TA.time_unit, 0)) * 60), "%H:%i") AS tempo_total ,…
-
1
votes1
answer59
viewsA: Add a new variable to a component (Picturebox)
The solution will be to create a class that extends the type PictureBox and add a property Vida: using System.Windows.Forms; namespace WindowsFormsApp1 { public class MyPictureBox : PictureBox {…
-
1
votes2
answers311
viewsA: Change tab of Tabcontrol
There are several ways to change the selected tab/tab in one TabControl. SelectedIndex tabControl.SelectedIndex = 1; SelectedTab // aqui a atribuição é feita pelo objeto do separador/tabulador…
-
0
votes1
answer92
viewsA: Error opening form inside panel
Apparently, from the image you put up, it seems that the Form are in a MdiContainer, where the code below can help you achieve what you want: Private Sub Button1_Click(sender As Object, e As…
vb.netanswered João Martins 5,597 -
0
votes2
answers923
viewsA: Access object attribute passed as generic parameter
Your problem is how you declared the properties in the class Usuario (or, in this case, did not declare! ), in addition to which put them all as Private, being impossible something "outside" to…
-
0
votes4
answers3071
viewsA: If condition in Where SQL Server
If the goal is to execute everything in just one query, you can do it as follows: SELECT * FROM tabela WHERE (@dataInicial IS NULL AND campoTabela <= @datafim) OR (@dataInicial IS NOT NULL AND…
-
2
votes1
answer104
viewsA: Does`Webbrowser` use any native windows browsers as a base?
The control WebBrowser of WinForms defaults to the version 7 IE, but this can be counteracted by changing a value in the Registry: Internet Feature Controls (B.. C) If in your code you always want…
-
1
votes1
answer40
viewsA: How to compare memory used by 2 processes
Your code can be greatly optimized, if what I understand is correct. I restructured it into the following: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TopMost = True…
vb.netanswered João Martins 5,597 -
1
votes1
answer27
viewsA: compare dates within the sql query
It’ll be something like this? SELECT aluno,title , dt_banco FROM liberar WHERE DATE_ADD(dt_banco, INTERVAL 10 DAY) < CURDATE() Basically the query is getting all records from the table liberar…
-
0
votes2
answers709
viewsA: How can I execute a function that is in another form?
Assuming you want to access the form frmMain from another evoked by that same Form, can do as follows: frmMain /// <summary> /// Método localizado em "frmMain" /// Criar uma nova instância do…
-
1
votes1
answer79
viewsA: Sum subquerys values separately
Try putting the SUM within each of the SUBSELECT instead of using them in the main query: select tb1.l1 * 0.3 , tb2.l2 * 0.3 from ( select setor , sum(total_geral) as l1 from mobile.auditoria where…
-
0
votes1
answer101
viewsA: Save xml as UTF8
For this just use one of the builders of the StreamWriter: using (StreamWriter myWriter = new StreamWriter("D:\\downloads\\Retorno.xml", false, Encoding.UTF8)) { myWriter.Write(ret); } In the 2nd…
c#answered João Martins 5,597