Posts by João Martins • 5,597 points
279 posts
-
0
votes1
answer320
viewsA: How to convert all ASCII written to text
The example available on Microsoft Developer Network I think it solves your problem: Dim unicodeString As String = "This string contains the unicode character Pi (" & ChrW(&H3A0) & ")" '…
vb.netanswered João Martins 5,597 -
0
votes1
answer44
viewsA: textbox with right align in VB print
I think the parameter StringFormat is able to solve your problem: Dim sf As StringFormat = New StringFormat() Dim font1 As New Font("Arial", 15, FontStyle.Regular) sf.LineAlignment =…
vb.netanswered João Martins 5,597 -
1
votes2
answers355
viewsA: Storing multiple values in the same column of the database, how much is it worth?
It all depends on how much information you want to store in one column and what you ultimately want to do with it. If it is just a few values, it may be worth it, since the space you will occupy in…
-
0
votes1
answer56
viewsA: I cannot assign a value inside my Label from a List
Here is your properly structured and optimized response :) namespace BetaTeste { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Form1_Load(object sender,…
c#answered João Martins 5,597 -
2
votes1
answer96
viewsA: Select where the month name appears?
I think for that just evoke the native method of Mysql, MONTHNAME: SELECT ROUND(SUM(c.potencia/12))/1000 AS potencia , MONTHNAME(c.data_criacao) AS mes FROM consumo c WHERE c.comodo_id = :id GROUP…
-
0
votes1
answer54
viewsA: Is it possible to interpolate a string already declared in C#?
The quick response: can not. The interpolation of string ($) works in the immediate, it is not possible to do it dynamically. If you use the string.Format("{0}") yes, then you can do more things…
-
0
votes1
answer165
viewsA: Clear Datagridview without firing Cellvalidating event
You can always create a control variable, which is true before doing the Rows.Clear() and passes to false immediately afterwards: private bool isClearing = false; // ... isClearing = true;…
-
0
votes1
answer252
viewsA: Map class to XML deserialization for C#
I think to do the Deserialize it is necessary that the classes are correctly configured with the tags XML. In the example below I put, I think (I have not tested), all the necessary settings for it…
-
1
votes1
answer408
viewsA: deserialize xml c#
Try it this way: namespace WsCliMotoristas { [Serializable] [XmlRoot("result"), XmlType("result")] public class Result { [XmlElement("resourceName")] public string resourceName { get; set; }…
-
4
votes2
answers111
viewsA: Write in search field date in dd/mm/YYYY format and search in the database in YYYY-mm-dd format
In Mysql there is the function STR_TO_DATE, you receive as a parameter your string date and converts to a valid date in the query SQL: SELECT STR_TO_DATE("01/12/2018", '%d/%m/%Y') Returns:…
-
0
votes3
answers162
viewsA: Program to rename files
I think this will solve your problem: string fileTitle = $"{fileName.Substring(0, 7)}{fileName.Substring(fileName.Length - 6, 6)}"; Perhaps it would also be better to validate if the string is large…
-
1
votes1
answer54
viewsA: Select do not return repeated based on a column
As the user @Thiagomagalhães posted will not work because the alias ce is not recognized within the INNER JOIN. Since ordering does not matter, the solution will be to get the address from a MAX:…
-
-1
votes2
answers220
viewsA: Is it worth putting two foreign keys on a table?
Considering there’s already a foreign key empresa_id on the table Clientes and a sale presupposes at all times a customer (through the field cliente_id, I suppose that’s NOT NULL), there will be no…
-
0
votes3
answers1061
viewsA: Knowing when your computer was Turned On / Off / Stopped
Can control at least the logoff and the shutdown as follows: using Microsoft.Win32; namespace MyApp { public MyClass() { SystemEvents.SessionEnding += SystemEvents_SessionEnding; } private void…
-
0
votes1
answer75
viewsA: Catch the hours of the day
The best way is to put this on a table. I think that in MySQL will work in the same way as in SQL (otherwise it will only be necessary to make one or the other): DECLARE @Hora INT = 0 CREATE TABLE…
-
-1
votes1
answer154
viewsA: Problem Reading Text File with Streamreader
Not sure what the purpose of the method is VerQualEmpresa, I think the most correct code would be: namespace TesteStreamReaderACBRSAT { public partial class LeituraArquivo : Form { string…
c#answered João Martins 5,597 -
2
votes3
answers189
viewsA: LEN function, know number of characters of a number
The solution to your problem is simple: DECLARE @Valor MONEY = 10.6879 SELECT LEN(CONVERT(FLOAT, @Valor)) -- 7 The difference to the example of @Leonardobonetti is the type of conversion data (FLOAT…
-
1
votes1
answer284
viewsA: VBA migration to C# - V10 (Teclapressionada)
The code will be something like this: public override void TeclaPressionada(int KeyCode, int Shift, ExtensibilityEventArgs e) { base.TeclaPressionada(KeyCode, Shift, e); int i =…
c#answered João Martins 5,597 -
0
votes1
answer682
viewsA: UPDATE with several records from another table
This query can solve your problem: UPDATE T3 SET T3.ID_T2 = T2.ID FROM T3 INNER JOIN T1 ON T1.ID = T3.ID_T1 INNER JOIN T2 ON T2.ID_T1 = T1.ID What it does is basically update the ID_T2 with the ID…
-
3
votes2
answers304
viewsA: SQL query unifying 3 tables
You can reach these values as follows: SELECT u.nome , IFNULL(t.totalterrenos, 0) AS totalterrenos , IFNULL(c.totalconversas, 0) AS totalconversas FROM users u LEFT JOIN ( SELECT iduser , COUNT(1)…
-
0
votes2
answers1600
viewsA: Compare the values of an entire column of Datagridview with a variable
A possibility is in itself SQL have a field with concatenation of all column values, for example using the FOR XML: SELECT (SELECT COLUNA1 + ';' + COLUNA2 FROM nome_da_tabela FOR XML PATH(''))…
-
0
votes1
answer460
viewsA: Datagridview - Sort column through a button
It is possible to make a Sort the columns after doing the Binding in this way: DataGridView1.Sort(DataGridView1.Columns("Name"), System.ComponentModel.ListSortDirection.Ascending) Anyway it is…
vb.netanswered João Martins 5,597 -
1
votes3
answers222
viewsA: Decimal problems in the SQL string
To avoid conversion issues, mainly in numerical or date variables, setting parameters from the SqlCommand is recommended. Example taken from Microsoft’s Developer Network: using (SqlConnection…
-
0
votes2
answers57
viewsA: Problem in a function parameter
The function getch() is used to read only one character.To read more than one (a number in this case) you must use scanf: int cNumber; scanf("%d\n",&cNumber)…
-
0
votes1
answer880
viewsA: Multiple rows in a Sql Server column
You can always try with a FOR XML: SET LANGUAGE us_english SELECT ( SELECT CONVERT(VARCHAR, ftd.DateAndTime, 113) + ';' CONVERT(VARCHAR, ROUND(ftd.Val, 2)) + ';' ttd.TagName FROM FloatTableDiario…
-
1
votes2
answers102
viewsA: Select with fields without values
Must exchange the INNER JOIN for LEFT JOIN, thus preventing the table code SB1 must be included in the other two tables. One aspect that may have an impact is that it does not validate NULL in the…
sqlanswered João Martins 5,597 -
1
votes1
answer338
viewsA: Scroll bar in incorrect position - Datagridview
If the goal is to put the Scroll always positioned on the last line, you can use the following code: dgwVenda.FirstDisplayedScrollingRowIndex = dgwVenda.RowCount - 1 As to the Scroll of DataGridView…
-
0
votes1
answer640
viewsA: My access is being denied by executing the following code
The problem may arise from two points: Write permissions in folder C:\Users\CAIO\Desktop\PDF's In this case assign write permissions to the user Lack of writing privileges from the own Visual Studio…
c#answered João Martins 5,597 -
1
votes1
answer140
viewsA: How to encrypt Stringconnection to a Mysql remote database in C#
If the ConnectionString is stored in app.config can always follow this very detailed tutorial on Codeproject:…