Posts by Thiago Loureiro • 2,465 points
113 posts
-
0
votes4
answers2082
viewsA: Compare a table field with another table
I would do it that way, if Count is higher than zero the municipality exists in your DB. I’m guessing your table has the Field Municipio and Id, ai Voce adapts to your need! declare @municipio…
-
0
votes1
answer229
viewsA: Connect to a local database c#
Use this way, is the most recommended using keyword using. var connectionString = @"Data Source=(LocalDB)\v11.0; AttachDbFilename=|DataDirectory|\BaseDeDados.mdf; Integrated Security=True; Connect…
-
1
votes1
answer104
viewsA: Dataconnectiondialog giving error in Visual Studio 2017
Good, the package you are using was taken from Nuget. The Owner has unlisted this package. This could Mean that the package is deprecated or shouldn’t be used anymore. Use this and it will solve…
-
0
votes3
answers878
viewsA: App.config to access an SQL Server database?
Here’s a full example of the.config app: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"…
c#answered Thiago Loureiro 2,465 -
0
votes1
answer678
viewsA: download and install Microsoft.Speech.Recognition
First you need to add the reference System.Speech to your project: var sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")); For more information on the component:…
-
1
votes5
answers1019
viewsA: Get piece of text inside a javascript word
You can use the IndexOf() When it returns -1 the string was not found var text = this.variable; var term = "jo"; if( text.indexOf( term ) != -1 ) alert(term);…
javascriptanswered Thiago Loureiro 2,465 -
2
votes1
answer223
viewsA: Livechart - Fill Cartesian Chart with Sql Server Query Data
Thiago, try it this way: XAML <Grid> <wpf:CartesianChart Series="{Binding SeriesCollection}" /> </Grid> C# private void LoadChart() { var strConexao = @"Data…
-
1
votes1
answer223
viewsA: How to clean another Window textbox? - WPF
You are creating a new instance of Window, consequently the control will be new and etc! To access controls in other windows with WPF, you need to declare control as public first, for example:…
-
2
votes1
answer133
viewsA: Store / Load generic types in Redis with C#
I bypassed the problem with the following solution: In the input method where I have Aspect I changed the types to dynamic. So the input and output is generic, using object also worked. For now I’ll…
-
0
votes1
answer949
viewsA: Project C# Closing Visual Studio
I’ve been through something similar, in my case it was an extension that was doing this. First of all I would check the application, if it has untreated exceptions, memory Leak among others.. but if…
-
1
votes1
answer133
viewsQ: Store / Load generic types in Redis with C#
Setting I created a function using AOP to cache information, when the method is called I store in Redis using the cache.StringSet, but when I need to capture back the value of Redis I need it to…
-
0
votes0
answers47
viewsQ: Opensource alternatives to Postsharp
Someone knows a good alternative Opensource at the Postsharp? I know it has the Free version, but I am developing some Nuget packages using attributes and I find the dependency of Postsharp heavy…
-
1
votes1
answer775
viewsA: Is there a possibility to compare schema between different databases in SQL Server?
Use this Script and adapt to your need: use master go DECLARE @Server1 VARCHAR(100) ='[LD38\SQLEXPRESS2005].'; --include a dot at the end DECLARE @DB1 VARCHAR(100) = '[TestDB]'; DECLARE @Table1…
-
1
votes1
answer38
viewsQ: Build problems with Postsharp in Appveyor
I’m having trouble doing build of my project in the AppVeyor, (locally works) because the license is in regedit. I checked that it is necessary to create a file postsharp.config and inserir license…
-
3
votes1
answer400
viewsA: Error accessing Automapper Createmap property 6.2.2
Createmap was modified from Mapper, has several ways to use, I will put the simplest that solves your problem: (https://github.com/IdentityManager/IdentityManager/issues/212) Utilize:…
-
8
votes1
answer279
viewsQ: What is the best type in SQL to use with Cryptocurrency?
I am developing a system where I will store transactions of Cryptocurrencies, type Bitcoin, I can not in any way have problems of conversion and rounding, in C# I checked and the best is decimal,…
-
2
votes1
answer84
viewsA: Read XML file, server returning error
Try this way with Webclient //string urlXml = "http://g1.globo.com/dynamo/tecnologia/rss2.xml"; string urlXml = @"http://migalhas.com.br/rss/rss.xml"; var data = ""; using (var wc = new WebClient())…
-
0
votes2
answers384
viewsA: Api that receives an Item Array
You can use the Dynamic public JObject PostSavePage(dynamic testObject) { return testObject; } would look like this : Update: Complete Controller of Example: using Newtonsoft.Json.Linq; using…
-
2
votes1
answer60
viewsA: Return number of cells according to parameter of a datatable
Using System.Linq; var ret = dt.AsEnumerable().GroupBy(x => x["c1"]).Where(x => x.Count() > 1); Full example: var dt = new DataTable(); dt.Columns.Add("c1"); dt.Columns.Add("c2");…
c#answered Thiago Loureiro 2,465 -
0
votes2
answers3016
viewsA: Doubt with Webrequest get method passing token
You are trying to send a Body in a GET verb where it is not possible. What you can and is most common is you send the token in Header. Example: Normally I do so, an example method of a test I did:…
-
1
votes2
answers259
viewsA: Insert Select Sql Server
Create clustered index in column CDLIGACAO If the records are unique it also places as primary key. CREATE CLUSTERED INDEX idx_name ON HISTORICO_LIGACAO (CDLIGACAO);…
-
2
votes1
answer431
viewsA: How to import XML from Data Dictionary to SQL Server?
Yes, it is possible, do the following: CREATE TABLE XMLwithOpenXML ( Id INT IDENTITY PRIMARY KEY, XMLData XML, LoadedDateTime DATETIME ) INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime) SELECT…
-
1
votes1
answer462
viewsA: How to cache c# . NET information for multiple users?
Pedro, you have some options. Distributed memory cache or cache, for example Redis. In memorycache you can store the key/value, as the example: protected MemoryCache cache = new…
-
1
votes1
answer820
viewsA: Return int in a select using Dapper.
Missing . Single() on your remote using (var connection = My.ConnectionFactory()) { connection.Open(); int idCidade = connection.Query<int>(sql).Single(); }…
-
0
votes1
answer648
viewsA: Import MS Access data to Sql Server via code
What I would do, imagining that your application is local: Create a stored synchronization database in the SQL database and a Linkedserver for the Access database. In this Stored Procedure would…
-
2
votes2
answers413
viewsA: Memory management and release
As you said, the using block is essential, whenever I can use the same, because it closes the connections and gives automatic device in the objects at the end of the clause. When you call Dispose()…
-
0
votes1
answer45
viewsA: Restarting progressibar count c#
Declares an int variable outside the Timer. then on your timer do it, very simple: private int segundos; private void timer1_Tick(object sender, EventArgs e) { segundos++; pro_separacao.Value =…
c#answered Thiago Loureiro 2,465 -
1
votes1
answer81
viewsQ: Capture Image Attributes with Javascript or Jquery via Url
I have an image that will be rendered in a Div, but I need to capture her Height because I need to treat it before putting it in the div (size). I don’t have the image on the screen, so I can’t do a…
-
0
votes2
answers113
viewsA: Error translating structure code from C++ to C#
Complementing the LINQ response public char[] nome; In C# you cannot initialize a field inside the struct, so you received the error.…
-
0
votes1
answer149
viewsA: Unrecognized class C# WINDOWS FORMS
You need to add the reference to the file msjro.dll Locate it on your PC, in my case it was on: C: Windows Winsxs wow64_microsoft-windows-m..…
c#answered Thiago Loureiro 2,465 -
1
votes1
answer173
viewsA: How to assign a List<> to a Datatable correctly windowns Form?
To convert Datatable to a list you must do the following: using System.Linq; ... List<DataRow> list = dt.AsEnumerable().ToList(); or IEnumerable<DataRow> sequence = dt.AsEnumerable(); To…
c#answered Thiago Loureiro 2,465 -
2
votes1
answer451
viewsA: How to join multiple commits from the same file?
You can do it like this: git reset --soft HEAD~3 git commit -m "GitCombinado com os ultimos 3" More details: https://gist.github.com/patik/b8a9dc5cd356f9f6f980…
-
1
votes1
answer292
viewsA: Is it possible to determine whether an array of bytes represents a pdf file that cannot be edited?
There is a solution without using the Byte Array using iTextSharp, with byte array found nothing, including in other searches all point to the components. PM> Install-Package iTextSharp using…
-
0
votes3
answers107
viewsA: Python - Variable problem
You need to use the global in the variable to use itself within a function #variaveis globais fcfs = False #commands def fcfscheck(): global fcfs fcfs = not fcfs A cool tip, I don’t know which IDE…
python-3.xanswered Thiago Loureiro 2,465 -
0
votes2
answers180
viewsA: Xamarin Webview Keyboard above the site
Try to do it in yours App.Xaml.Cs using AndroidSpecific = Xamarin.Forms.PlatformConfiguration.AndroidSpecific; AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this,…
-
1
votes1
answer132
viewsA: How to create a button for each Listview item that accesses a song
In the Selectedindexchanged Event you can play the song by doing the following. Install the Naudio package (Package Manager Console) - Nuget Install-Package Naudio If you want a song to touch the…
-
0
votes2
answers115
viewsA: Sending email C# Error Invalid HELO name
I use in my projects (I use the email for this) and my code is like this, adapt to your need and test there: Check if you need SSL and default Credentials tbm. public static void Send(Email email) {…
c#answered Thiago Loureiro 2,465 -
1
votes1
answer849
viewsA: Delete a record from the database when the deadline is passed
DELETE FROM table WHERE data_termino < '2017-09-21 00:00:00'; or if it is a higher date use > .. and so on You can do something more automated for example: (last 6 months) delete from table…
-
2
votes1
answer686
viewsA: How to draw words from an array without repeating them?
First declare a Random Random rnd = new Random(); Make the Random take a value in the middle of the array by the generated Random in the index int r = rnd.Next(times.Length); Now you can get your…
-
0
votes2
answers85
viewsA: Change column data
using (SqlCommand cmdadd = new SqlCommand("UPDATE Usuario set Cadastro = @Cadastro where xxx = @yyy", connection2)) { cmdadd.Parameters.Add(new SqlParameter("@Cadastro", false));…
-
3
votes2
answers933
viewsA: If I directly copy the Visual Studio project folder gives any error? Or do I have to do something else?
Copy all including the file . SLN Or you can do something nicer and put in Git. http://gabsferreira.com/criando-e-enviando-arquivos-para-seu-repositorio-no-github/…
-
2
votes2
answers1855
viewsA: Stopwatch construction
Use the Stopwatch in the C# Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (; ;) { Console.WriteLine(stopwatch.Elapsed); } In WPF you can do so, but it can greatly improve this code:…
-
2
votes2
answers3598
viewsA: How to consume webservice (WSDL) mails with javascript
You have many options, with JSON (more practical and easy) would look like this (using Jquery), in my example I am using VIACEP, works well too :)…
-
1
votes2
answers142
viewsA: Delete all references that are not in use in Visual Studio?
The Resolveur solves your problem if you do not choose to use Resharper.…
-
1
votes2
answers220
viewsQ: What is the best way to treat Exceptions and Log in Webapi (C#)?
Setting: Webapis in . NET 4.x Goal: Improve Logging (info, error, debug, Warning) and Exception Handling, for example, log in exceptions, which Log frameworks do you use? Where do you store Logs? I…
-
0
votes1
answer135
viewsA: Log4net stopped showing logs
There are 3 items you need to check. 1- App.Config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net"…
c#answered Thiago Loureiro 2,465 -
8
votes1
answer147
viewsA: Error doing UPDATE when setting varbinary variable as`null`
Matheus you need to change the null for Sqlbinary.Null, many people had this problem with null and varbinary values in the bank! int count = ctx.Database.ExecuteSqlCommand( $"UPDATE dbo.Table " +…
-
1
votes1
answer56
viewsA: When you get to 12:00 every day write on the console
Creates a Timer and then compares with the chosen time: private static void Main(string[] args) { var t = new Timer(TimerCallback, null, 0, 1000); Console.WriteLine("Pressione \'q\' para sair.");…
c#answered Thiago Loureiro 2,465 -
1
votes2
answers662
viewsA: How to transform a json object array into a list of objects in c# using Json.NET
Complementing Carlos' response, I also like to use Newtonsoft being like this: string jsonString = @"{""tempoexibicao"": 10,""canetas"":[{""cor"" : ""azul"",""marca"" : ""bic""},{""cor"" :…
-
2
votes3
answers68
viewsA: How is Join and WHERE made with multiple tables?
Just add the other relationships in Join SELECT C.nome_curso, A.username, M.nome_modulos, MA.nome_materias FROM aluno A JOIN cursos C on C.id_cursos = A.curso_id JOIN modulo M on M.id_modulos =…