Posts by Rovann Linhalis • 14,881 points
567 posts
-
2
votes2
answers163
viewsA: File.Exists and the accentuation
It is possible that the file name string is being encoded in HTML, you can reverse this by using HtmlEncode and HtmlDecode: string arquivo = "Imagem-com-acentuação.jpg"; string codificada =…
-
1
votes1
answer35
viewsA: return only to your last move of each code
If the table structure is the one you’ve pasted, it’s enough: Select cd_item, max(dt_mov) as ultima_data from movimentacao group by cd_item
sqlanswered Rovann Linhalis 14,881 -
1
votes3
answers1428
viewsA: (SQL) In parentheses in the WHERE clause
It’s just a matter of precedence of operators where "An operator at higher levels is evaluated before an operator at a lower level". In other words, AND is processed before OR. true and false and…
-
6
votes4
answers327
viewsA: Return results for all months of the interval
First you need to generate the sequence of months: SELECT m.mes, MONTHNAME(STR_TO_DATE(m.mes, '%m')) AS nome_mes FROM ( SELECT d1+d2*10 AS mes FROM (SELECT 0 AS d1 UNION SELECT 1 UNION SELECT 2…
-
3
votes2
answers638
viewsA: error: "table sales has 6 Columns but 5 values Were supplied"
When executing the query without specifying the column name, the database has no way of knowing which value should be inserted in which column. In the code: INSERT INTO vendas VALUES…
-
2
votes1
answer3919
viewsA: How to list every day between two dates for more than one record (Oracle)
Updating: Due additional explanation, where the need would be to determine the time the person stayed on site, I made the following command: with dias as ( select (e.x + level -1) dia from (select…
-
0
votes1
answer174
viewsA: doubt C# stack
on line 103, you are closing the while before passing by ifs, just remove the } and close after the last if
c#answered Rovann Linhalis 14,881 -
4
votes1
answer157
viewsA: Error converting varchar to integer
By not specifying the Dbtype of the parameter, SqlCommand is interpreting it as whole, and thus the character | in the SQLServer is an operator OR bitwise. If you execute the following command:…
-
1
votes2
answers641
viewsA: Calculate more than one text box and display in a specific text box
You can create a class, representing the payment, and associate an object of that class in the DataBind of textBox. The calculations are all performed in the class, Form only takes care of the…
c#answered Rovann Linhalis 14,881 -
1
votes2
answers78
viewsA: Method without any code
As leandro mentioned in the comments, I believe I’m trying to see the code of the method pressing F12 and this appears: As shown in the image, from metadata this means that the method is coming from…
c#answered Rovann Linhalis 14,881 -
0
votes1
answer29
viewsA: How to create file at runtime?
I don’t know if this will solve your problem, but focusing only on writing the file: Method 1: System.IO.File.WriteAllText("C:\\arquivo.extensao", "conteudo", Encoding.Default); Method 2: string rtf…
-
2
votes1
answer541
viewsA: Storage of List-like variables in an SQL-Server database
Solution 1: You can have 4 tables: Jogadores : Stores the player. Jogos : Stores the games. Habilidades: Stores all the skills of a game. Relacao : Lists what abilities a player has, these in turn…
-
3
votes2
answers703
viewsA: quote and quotes in a string (leaving " or #39; in the View)
Simple quotes is for char, so the #39 (ASCII code). And double quotes is for starting or finishing a string. If you need to place one in the middle of the string, use an escape character: \:…
-
3
votes1
answer338
viewsA: How to detect version of Windows OS?
I use the ManagementObjectSearcher namespace System.Management Example: string r = ""; using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))…
-
2
votes2
answers349
viewsA: Invert id sequence in a table
I believe it is correct the way it is... the display problem may be caused by another factor, configuration perhaps. If you reverse the sequence, the next post, would be code 115 and would be right…
-
3
votes1
answer43
viewsA: Select on condition
One option is not exists: Select distinct t.Local, t.COR from tbl_Local t Where t.COR = 'RED' and not exists (select 1 from tbl_Local x where x.LOCAL = t.LOCAL and x.COR != t.COR); I took advantage…
-
3
votes1
answer591
viewsA: Bring forward an already open program - C#
whereas: Application instance "A" running. Open a new instance "B". Instance "B" checks whether another instance is already running. Positive result, "A" is running. Closes instance "B". You want…
c#answered Rovann Linhalis 14,881 -
0
votes3
answers437
viewsA: Postgresql 8 - Replace the first occurrence of a character in a string
You can use the function Position to find the first occurrence of the hyphen in your string. After that, you can replace it with space, using the function Overlay: select overlay('Palavra-Teste-X'…
postgresqlanswered Rovann Linhalis 14,881 -
2
votes1
answer42
viewsA: Map sub-property
your class should be something like: public class LigacaoGet { public int Fila { get; set; } public string Telefone { get; set; } public string Nome { get; set; } public string Email { get; set; }…
-
4
votes1
answer3181
viewsA: Decimal places c#
You can: Keep the value, just change the display: decimal x = 270.61864847349717630804948048M; Console.WriteLine(x.ToString("N3")); Upshot: 270.619 Round up: decimal y = Math.Round(x,3);…
-
1
votes2
answers119
viewsA: Call Method C#
You have to use Paint’s Event Form. It must be something like that: private void Form1_Paint(object sender, PaintEventArgs e) { if (String.IsNullOrEmpty(txtNomeFuncionario.Text))…
c#answered Rovann Linhalis 14,881 -
0
votes1
answer146
viewsA: VB.NET - How to delete files being used by other process
The operating system blocks the file and you won’t be able to change it. This type of situation usually occurs when the file is being used by another user, albeit on the same computer, or on another…
vb.netanswered Rovann Linhalis 14,881 -
1
votes1
answer193
viewsA: Reset the priority of a record in the table
If you don’t have one UNIQUE in the priority column, you can do two update commands, but you will have to test before you are increasing or decreasing the registry priority: If you’re lowering the…
-
4
votes3
answers1618
viewsA: Encoding string conversion
Convert to bytes, and then to string again using another encoding: string x = "Cinto De Segurança"; byte[] bytes = Encoding.Default.GetBytes(x); string y = Encoding.UTF8.GetString(bytes);…
-
2
votes1
answer143
viewsA: How to call a Function in c#
You can call the submitForm() with the method InvokeScript webBrowser1.Document.InvokeScript("submitForm");
c#answered Rovann Linhalis 14,881 -
3
votes1
answer51
viewsA: How to select and play values in the same column
An alternative is the UNION : select 'a' as letras union select 'b'
-
0
votes1
answer247
viewsA: decimal field minus comma c#
That Calculation: string distribuicao = "1"; string percentual = "0,77"; string disponivel = "113"; decimal quantidade = decimal.Parse(disponivel) * decimal.Parse(percentual) +…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer481
viewsA: Return selected object in datagridview
Changing a little if DataGridView: List<ModelAluno> alunos; ModelAluno aluno = new ModelAluno(); public PesquisaAluno(List<ModelAluno> _alunos) { InitializeComponent(); this.alunos =…
-
3
votes1
answer66
viewsA: Selection with LEFT JOIN
You can use the GROUP_CONCAT SELECT contatos.id as id_contato, contatos.nome as nome, contatos.sobrenome as sobrenome, GROUP_CONCAT(contatos_telefone.telefone SEPARATOR ',') AS telefones FROM…
-
1
votes1
answer453
viewsA: Delete Rows in several tables dynamically in Postgres
I did the following function: Selects all tables, from the informed schemas, which contains the informed column, and traverses by running delete: CREATE OR REPLACE FUNCTION public.delete_from_tables…
-
1
votes3
answers250
viewsA: How to select only the largest drive in Sql?
Assuming the product identification, is just the gtin, you can use rank with Partition: rank() OVER (PARTITION BY produto.gtin ORDER BY estoque.id desc) ps. Sort by sale number, you will have…
-
2
votes3
answers838
viewsA: Check Whether Datagridview field of type Datagridviewcheckboxcolumn is marked
I did an extension method for DataGridViewCheckBoxColumn, so you can use in a simpler way: Method: public static List<DataGridViewRow> CheckedRows(this DataGridViewCheckBoxColumn c) { return…
-
3
votes1
answer81
viewsA: Very slow query to export in excel
Early on you can take out all these ToList() and run the query only at the end. Example: var tbl_caminhos = db.tbl_caminho_backup.AsNoTracking().Where(x => x.ativo &&…
-
2
votes1
answer94
viewsA: How to find out if TCP Listener is listening?
You can change the Timeout of the client: TCPClient.ReceiveTimeout = 5000; TCPClient.SendTimeout = 5000; Note that a very short timeout can cause problems during communication.…
-
1
votes1
answer456
viewsA: Traverse attributes of an object that is in a list in C#
Change if (cidadaos.Count >= 0) for if (cidadaos.Count > 0). You’re getting into the if even if there is nothing in the list, which generates the error.…
-
1
votes1
answer313
viewsA: Richtextbox specific line in bold
I took the following method from within the code of RichBoxExtended, I didn’t make it, but it might help you: public void ChangeFontStyle(FontStyle style, bool add) { //This method should handle…
-
5
votes2
answers905
viewsA: How to create a sequential number that does not repeat, per user
According to the documentation: The default value of a column is the value that will be inserted if a new row is inserted, but no value is specified for the column. and, You can also specify an SQL…
-
2
votes1
answer1101
viewsA: SQL SERVER - return different columns from an Inner Join on the same row
In a simple case like this, of only two columns, you can use sub-selects, and create the columns manually. In more complex cases, it could make a pivoting table. Considering your current model this…
-
3
votes2
answers252
viewsA: Timer telling you when it’s over
The interval of timer it has to be 1 second, because every second it will check if it is time to clear the console, or if it is <= 5, write on screen 5...4...3...2...1... In another variable, you…
c#answered Rovann Linhalis 14,881 -
3
votes1
answer113
viewsA: Serealize a JSON String C#
You need to create separate classes, and within the class Pessoa you will have a class object Familia: public class Pessoa { public string nome { get; set; } public Familia familia {get;set;} public…
-
2
votes1
answer469
viewsQ: Convert an object that implements the interface into its own interface
I made the following code: using System; public class Program { public static void Main() { //Este método funciona Metodo(new ClasseTeste(){ Obj = new Registro(){ Nome = "Nome Teste"}}); //Este não…
-
1
votes1
answer28
viewsA: I am making a simple program to study Vectors, when I run it appears the error "Index was Outside the Bounds of the array" on line 24
change your go for (i=1; i<=n; i++); for for (i=0; i<n; i++); The indices of array begin at 0, then at a array size 5, the indexes will be: [0], [1], [2], [3], [4] That is, it starts at 0, and…
-
1
votes1
answer1443
viewsA: Integration of SQL Server with Android
I think you’re missing your connection string: ConnectionURL = "jdbc:jtds:sqlserver://" + server + database + ";user=" + user+ ";password=" + password + ";"; Should be: ConnectionURL =…
-
2
votes1
answer42
viewsA: Create a column for each row returned from Select
I think your end result would be this: select * from crosstab ( 'with dados as ( SELECT public.impressoras.patrimonio, public.impressoramodelo.modelo, public.impressoralocal.descricao, data,…
postgresqlanswered Rovann Linhalis 14,881 -
2
votes1
answer568
viewsA: Access a C# thread-based method object with Winforms
You can use the control Invoke method to do this: cmd.CommandTimeout = 0; Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; string sql = @" *CONSULTA* "; cmd.CommandText = sql; DataSet…
-
1
votes2
answers134
viewsA: Help to simplify query sql
You can store the result of these queries with the With: with gravidas as ( select l.no_cidadao, extract(year from l.dt_cad_individual) ano, extract(month from l.dt_cad_individual) mes,…
-
3
votes1
answer88
viewsA: Conversion from Hex to Decimal using Two Add-on
I found the solution: public static Single ConvertHexToSingle (string hexVal) { try { int i=0, j=0; byte[] bArray = new byte[4]; for (i = 0; i <= hexVal.Length-1; i += 2) { bArray[j] = Byte.Parse…
-
5
votes2
answers4982
viewsA: How to count the number of records of a selection in a table
For "How many different specialties there are", Simple: select count(distinct especialidade) as qtd_especialidade from funcionarios or to "How many records there are by specialty: select…
sqlanswered Rovann Linhalis 14,881 -
1
votes1
answer225
viewsA: Remove Dynamic Picturebox
Just in the event of the button, you remove the pb of flpFotos: btn.Click += delegate { flpFotos.Controls.Remove(pb); };
-
2
votes2
answers549
viewsA: Return default value if no record
You can use the function generate_series to generate the numbers from 1 to 12 (months) and from there, search your records. See: select g, to_char( to_timestamp(to_char(g, '999'), 'MM'), 'TMMon') as…
postgresqlanswered Rovann Linhalis 14,881