Posts by João Martins • 5,597 points
279 posts
-
2
votes1
answer2433
viewsA: Postgresql - Partial Foreign Key of Composite Primary Key
considering all comments, and in particular the indication of @rhubarb, will this solve your problem? CREATE TABLE table1 { dummy_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, id BIGSERIAL…
-
1
votes1
answer516
viewsA: Passing Date parameters for queries
The problem is the value you are passing for the parameters, which will be an object of the type DateTimePicker (or something like that) instead of a value like DateTime. Change the code to the…
-
2
votes1
answer528
viewsA: Error: SQL Server String or Binary data would be truncated
The problem is in the fact of its field DupNossoNumBco be only large 20 (according to the information made available in comment) and the variable @numero1 reach out to 28 characters: --…
-
3
votes1
answer1039
viewsA: How to change the color of the line below Edittext via xml
Try doing it this way: <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Something or Other"…
-
2
votes1
answer455
viewsA: Return Result of an IF executed by Command Prompt(CMD) in C#
Instead of validating by IF whether the file exists or not, you can always remove it after the end of the process if : // espera o cmd.exe terminar process.WaitForExit(); string strFile =…
-
0
votes2
answers389
viewsA: Sum the value of the column by grouping monthly and by product
The query you put in SQL Fiddle was almost complete, just needed to group by date and put the condition of 12 months: SELECT FirstDate AS [Date] , Product , SUM(License) AS [TotalLicense] FROM…
-
5
votes5
answers1894
viewsA: Test for string fill
I believe that the question of the performance of the first two examples is related to the fact that they are validating the content of string, where in the third example, more performant, we’re…
-
7
votes2
answers106
viewsA: Help with select and repeat records
The table structure is not exactly "great". If what you want is to have an update history then you should, as you rightly say, @Dudaskank, is to change the data type of DATE for TIMESTAMP to be able…
-
1
votes1
answer47
viewsA: WPF C# Current position of Mdichild?
You can use the method PointToScreen to know where the MdiChild: child.PointToScreen(new Point(0,0)) If you still have difficulty getting the position, you can try from the MdiParent:…
-
1
votes1
answer35
viewsA: How to put zeros after type checker - sql server
I think the solution lies in something like this: SELECT LEFT(@vNossoNumero, 2) + REPLICATE('0', 9) + RIGHT(@vNossoNumero, LEN(@vNossoNumero) - 2) Or so: SELECT SUBSTRING(@vNossoNumero, 1, 2) +…
-
2
votes1
answer133
viewsA: Passing a Connection string dynamically
The problem is in SelectedValue, that remains the null when you click the button. The solution is to obtain the class instance Planta and get the value there. In the Form_Load can slightly optimize…
-
3
votes1
answer55
viewsA: How to make a select based on data from another table
To avoid catching users who have already given like would have to make a LEFT JOIN with the table app_likes: $teste = $app->database->query(" SELECT user_id , user_firstname , latitude ,…
-
3
votes1
answer464
viewsA: Excel file reading with more than 1 sheet in the same file using C#
The SQL command you are running on OleDbCommand is that "controls" the information you are getting on Excel sheets. To read the other sheets just change the table name: // Folha "Endereco" string…
-
4
votes3
answers3810
viewsA: What is the difference between a View and a Stored Procedure in SQL?
VIEWS One VIEW is basically a consultation sql, where we built a query, usually more complex than a simple SELECT, and then we can use it as a table. Example CREATE VIEW V_Exemplo AS SELECT T1.Id ,…
-
0
votes2
answers168
viewsA: As the value within a <td>text</td>
To manage web pages on Vb.net can use a fantastic library, HTML Agility Pack. With this pack can obtain specific information very easily by using Xpath (tutorial here: Xpath W3 Schools Tutorial),…
vb.netanswered João Martins 5,597 -
1
votes2
answers446
viewsA: How to pick up snippets between () a string
If you only want to get what is inside parentheses (by removing the parentheses themselves) you can use the following regular expression: string formula = Console.ReadLine(); string trecho =…
-
2
votes1
answer62
viewsA: Pick a certain number from a string in select
The code below allows you to achieve what you want: DECLARE @strText NVARCHAR(MAX) DECLARE @intAlpha INT SET @strText = 'CreditCash_Aderencia_AD_20180823;20180823;Arquivo convertido para CSV com 503…
-
3
votes1
answer3378
viewsA: Mask for phone and mobile phone (8 or 9 digits) in the same textbox winforms
If you want to apply the mask only when the focus out of control, can evoke this method: string AplicarMascaraTelefone(string strNumero) { // por omissão tem 10 ou menos dígitos string strMascara =…
c#answered João Martins 5,597 -
0
votes2
answers4833
viewsA: Error: Invalid thread operation
It can always validate whether the control needs to effectively evoke the Invoke: video.NewFrame += (s, b) => { if(pictureBox1.InvokeRequired) pictureBox1.Invoke(new Action(() => {…
c#answered João Martins 5,597 -
1
votes1
answer645
viewsA: Mask for formatting Textbox
The problem will be that the String.Format cannot convert a String to a numerical format. Try converting the phone number that comes from TextBox for a number and then apply the mask: string…
-
1
votes2
answers137
viewsA: Show Groupby List using Lambda in view. ASP.NET MVC
When using the GroupBy in your consultation Linnum is modifying the data type of the result, so it is defined that the information should be in the format IEnumerable<GaragemModel.Vr> you…
-
1
votes2
answers406
viewsA: Select dates that are not in the table
You can try something like that (untested code!): DECLARE DataInicial AS DATE DECLARE DataAtual AS DATE CREATE TEMPORARY TABLE TmpDatas (Data AS DATE) SET DataInicial = STR_TO_DATE('01/' + CAST(@Mes…
-
1
votes2
answers507
viewsA: How to place a url on the web.config
I guess I could put it on the appSettings of web.config: <appSettings> <add key="myUrl" value="http://localhost:56137/api/GetFuncionario"/> </appSettings> Then to get the value:…
-
5
votes2
answers228
viewsA: Is Tuple the same as creating an object?
Personally I think that the Tuple should be used when we need to simplify something in the code, an excerpt that needs a simple structural validation, with Item1 + Item2 where we do not necessarily…
-
1
votes4
answers283
viewsA: Create list with more than one element as if it were multidimensional
Perhaps the most viable way to create a list is to Dictionary<string, string>, creating a list of KeyValuePair. Dictionary<string, string> dictionary = new Dictionary<string,…
-
1
votes3
answers51
viewsA: I can’t get average
There is a specific function for SQL averages, AVG: SELECT cod_pessoa AS CodPessoa , dat_compra AS DataCompra , vlr_compra AS ValorCompra , cod_transacao AS CodigoTransacao , AVG(qtd_itens_compra)…
-
2
votes2
answers103
viewsA: Transforms string to decimal within an object
Here a "clean" solution with Regex: using System.Text.RegularExpressions; public async Task PostFuncionarioVM(FuncionarioViewModel funcionario) { var uri = new…
-
0
votes2
answers85
viewsA: IF condition in Datagridview
It was almost there in the code you put in your question! If Convert.ToString(Me.DataGridView1.CurrentRow.Cells(0).Value)(0) = "5" Then…
-
5
votes2
answers1324
viewsA: Return 0 when SUM is NULL
Just put a IFNULL in your consultation: SELECT IFNULL(SUM(coluna1 + coluna2 + coluna3), 0) AS Soma FROM table WHERE nome = 'funalo' AND MONTH(data) = 09 AND YEAR(data) = 2018…
-
0
votes1
answer226
viewsA: Filter on gridview, how to do?
Try using dynamic SQL within your SP. You just have to change the way your SP does the query: DECLARE @SQL NVARCHAR(MAX) SET @SQL = ' SELECT * FROM t_livros WHERE ' + @OPCAO + ' LIKE ''' +…
vb.netanswered João Martins 5,597 -
0
votes1
answer48
viewsA: Error opening platform V10 - Cannot perform Runtime Binding
This issue is resolved by the application of a AssemblyResolver: static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string assemblyFullName;…
vb.netanswered João Martins 5,597 -
0
votes1
answer218
viewsA: Pass object to proc sql server
You can serialize the object and pass it to SP as XML, then transport the information to a temporary one and work with it: You need to slightly change the class Funcionario: [Serializable]…
-
0
votes2
answers121
viewsA: Problems with values passed to Static variables with class on the server
Complementing the response of @Carlosalmeida, can save the value in session, but if you want to keep the page "alive" for more than 20 minutes, you should set the timeout of the session in your…
-
1
votes3
answers77
viewsA: Find an index of a value in a matrix
I think this might solve your problem: int index = list.FindIndex(a => a == "Elefante"); Do a linear search to get the index.
-
1
votes1
answer64
viewsA: Map windows Forms controls
Put the class Pessoa to notify changes in ownership (through interface INotifyPropertyChanged), as follows: class Pessoa : INotifyPropertyChanged { private string nome; public string Nome { get {…
-
1
votes1
answer51
viewsA: How to ensure that all information was recorded at the bank?
You will have to work with transactions, so that if nothing happens, do Commit changes and everything is stored consistently in the database, otherwise Rollback so that nothing is recorded so as not…
-
0
votes3
answers283
viewsA: How to break line after 29 digits C#?
You can use the Take (using the library System.Linq) to get just the number of characters you want, and go adding the line-breaking text to the TextBox: // exemplo com texto fixo string strText =…
c#answered João Martins 5,597 -
2
votes1
answer268
viewsA: Select of Product Structure
It is possible to arrive at the result you want in two ways: creating a temporary table and filling, row by row, from a CURSOR (or loop), which is more laborious because it will have to make the…
-
1
votes2
answers392
viewsA: SQL Server - CONCAT + IF in VIEW
The simplest way is to apply a ISNULL in the column GRPECON_DESCRIÇÃO: SELECT CONCAT('Total de ', CAST(COUNT(E.ID_GRUPOECONOMICO) AS VARCHAR), ' cliente(s) ' + ISNULL(GP.GRPECON_DESCRICAO, 'SEM…
-
1
votes2
answers436
viewsA: SQL parameter in PDO PHP does not work
Try making a bindParam instead of passing the array of parameters in the execute: $dbh = new PDO('sqlite:db_coleta.sqlite3'); $usuario_id = 150; $sth = $dbh->prepare('SELECT * FROM ROTA_VIEW…
-
2
votes1
answer150
viewsA: How can I compare two listbox items one by one
If the elements in the ListBox are of the type string, then the code below solves the problem simply (necessary to import System.Linq): Dim listHash = ListBox1.Items.Cast(Of String).ToList() Dim…
vb.netanswered João Martins 5,597 -
1
votes2
answers72
viewsA: Textbox changes the value to decimal (EN) when pressing the TAB, however I want to leave currency (REAL) the field
In the event of LostFocus there is always the possibility to convert/force the value to the format we want: NumberFormatInfo numberFormatInfo = new NumberFormatInfo(); // número de casas decimais…
-
2
votes1
answer62
viewsA: How to view the columns of a system view in SQL Server?
Try it this way (I’m guessing the name of VIEW is teste): SELECT AO.name AS [View Name] , AC.name AS [Column Name] , ST.name AS [Type] FROM sys.all_objects AO INNER JOIN sys.all_columns AC ON…
-
0
votes3
answers58
viewsA: Condition does not contain in Datagridview
So without testing, only with Notepad++ really, I think this would solve: private void btAnalisar_Click(object sender, EventArgs e) { if (radioButtonNotasAusentesConsisaNet.Checked) { foreach(var…
c#answered João Martins 5,597 -
-1
votes2
answers199
viewsA: Multiline textbox printing last item only
If the goal is to separate line by line, the best way will be: string leitor; while ((leitor = ler.ReadLine()) != null) { textBox1.AppendText($"{leitor}{Environment.NewLine}"); } Placing the…
-
0
votes2
answers62
viewsA: Search images across subdirectories
I think this solution is quite comprehensive: // se pretender ter várias pastas List<string> diretorios = new List<string>() { @"C:\Pasta1", @"C:\Pasta2", @"C:\Pasta3" }; // se pretender…
c#answered João Martins 5,597 -
1
votes2
answers672
viewsA: How to open the notepad with contents inside without saving?
Why not create the file in the user’s temporary and then delete it? private void CreateTempFile() { string strTempFile = $"{Path.GetTempPath()}{Path.GetRandomFileName()}.txt"; try { using…
c#answered João Martins 5,597 -
0
votes1
answer320
viewsA: How to get the Commandtext from a Iqueryable?
There is a here an example that can help or even solve your problem: using System; using System.Data.Entity.Core.Objects; using System.Linq; using System.Linq.Expressions; using System.Text;…
-
2
votes2
answers159
viewsA: How to separate a letter from a Character in SQL?
I think the simplest will be (using the 3rd letter hint): SELECT * FROM fnord WHERE substr('illuminati', 3, 1) = 'a' The first parameter is a string that you want to validate, 2º is the index and 3º…
-
2
votes2
answers267
viewsA: SQL helps to join 2 selects
I believe that in this way you will achieve the results you want: SELECT DISTINCT TMP.* FROM ( SELECT DISTINCT d.cat_id AS prod , p.id , p.nome AS id_prod , SUM(d.qtd) AS qtd_prod ,…