Posts by Marco Souza • 12,304 points
506 posts
-
1
votes2
answers186
viewsA: How to select single data from a Join conditional?
See how to do below, this solution was made in SQL SERVER, but select is equivalent to mysql. declare @servers table ( id int, ip varchar(255) , votes int, port varchar(255), hash varchar(255),…
-
1
votes1
answer35
viewsA: Total sum with Line
Your question doesn’t have many details, but if you’re wanting to show a grid as you showed at the beginning of the question would look like this; var _total = from cta in ListConta() .Where(c =>…
-
3
votes1
answer179
viewsA: Visual Studio 2012/2015
Carol, In Visual Studio, when we create a new project we have the option to choose between the language C# (C Sharp), VB (Visual Basic) among others, so mind the choice of language when creating…
-
0
votes2
answers391
viewsA: Is there a difference between First and Single?
The subtle difference between First and Single is that the latter imposes the rule that the database query should return only one record. To ensure such restriction, the Single method issues a…
-
0
votes2
answers391
viewsQ: Is there a difference between First and Single?
There are some differences between First and Single? the return of the two consultations are equal? And in the performance between the two is the same? Which of the two expressions is best used?…
-
1
votes1
answer2397
viewsA: Mysql connection problem - Connection must be Valid and open
From what I’ve observed, you’ve created two variables; private MySqlConnection cone = new MySqlConnection(); private MySqlCommand comandoSql = new MySqlCommand(); that you use in some of the methods…
-
0
votes1
answer1256
viewsQ: How to format`Datetime? ` in dd/mm/yyyy format using Linq?
I have the query below, but while trying to format the field Data_nascimento and Data_exclusao with the .ToString("dd/MM/yyyy") returns me to an error at runtime. The 'System.String…
-
1
votes3
answers2377
viewsA: Structure table day and times (schedule type)
According to comments you described, you have a relationship between COMPANY and Schedules of 1 p/ Many, that way I’d do it this way. declare @Empresa table ( id int, nome varchar(50) ) declare…
-
1
votes3
answers75
viewsA: How can I exclude the penultimate number from a period?
If your goal is to always remove the 0 on the left, just use the DAY, he returns a int of the value passed, as the int always sets the 0 to the left you will have removed it by default. declare…
-
1
votes2
answers2443
viewsA: How to get data from the previous line in SQL?
If your id is always auto increment, just do a sub-select and pass the id - 1 of the external select. declare @teste table ( id int, title varchar(10), time time, domain varchar(10) ) insert into…
sqlanswered Marco Souza 12,304 -
5
votes1
answer368
viewsA: How to remove duplicated rows by holding other columns
User the Group by and the min(), declare @tabela table ( id int, title varchar(20), time time, domain varchar(30) ) insert into @tabela values (32, 'title1', '12:30' , 'domain65.com'), (33,…
-
2
votes2
answers1291
viewsQ: What is READ_COMMITTED_SNAPSHOT?
What is READ_COMMITTED_SNAPSHOT EF6 Transaction Support About Anyway? What is your use within the Entity Framework?
-
3
votes2
answers1303
viewsQ: What is the difference between creating a Context with Dbcontext and Datacontext?
What is the difference between creating a Context with Dbcontext and Datacontext? Is there any difference in performance or best practice between one or the other? See the examples below; namespace…
-
0
votes1
answer61
viewsA: How do you convert this Sql to Entity framework?
You didn’t give much detail of the model, but your query in Brasili would look like this. var PontoDeColeta_Material = (from t1 in Context.PontoDeColeta join t3 in Context.Material on t1.IDMaterial…
-
11
votes2
answers283
viewsQ: What is the difference between using a comparison with >= or simply >?
Imagine the following scenario. int i = 2; if(i >= 2) { //.... } When we could just summarize to; int i = 2; if(i > 1) { //.... } My doubts with these two expressions are as follows:: When a…
-
2
votes1
answer88
viewsA: Do Not Insert PHP and MYSQL Equal Values
Well, you didn’t pass the table structure, but in case you need some more specific detail, you’d better post that part. With what you have, you can do the following to test if there is email with…
-
8
votes2
answers2458
viewsQ: What is the purpose of Transactionscope blocks?
I have a code with several blocks TransactionScope and I didn’t quite understand its purpose. ModeloColDataContext dm = DataContextFactory.GetContext(usuario); { if (documento > 0) { using…
-
2
votes2
answers212
viewsA: Error in Trigger
Try to land this way. CREATE OR REPLACE FUNCTION public.atualiza_status_tag() RETURNS trigger LANGUAGE plpgsql AS 'begin IF NEW.gado_status = 'Inativo' THEN UPDATE TAG SET tag_status = 'Disponivel';…
-
1
votes1
answer4608
viewsA: How to compare a date of type datetime?
The most simplified way to do this is simply by comparing one date to the other where data = @Data, see the examples below. declare @Data datetime = cast('01/01/2016 12:50:00.000' as datetime)…
-
6
votes2
answers687
viewsQ: How is the query generated in Linq mounted when we do UPDATE?
How the query generated in Linq is mounted when we do UPDATE? using ColWebDBContext.DBase.Banco; using System; using System.Web.UI; using System.Linq; namespace DBContext { public partial class…
-
1
votes3
answers899
viewsA: Convert data c#
You can use the Tryparseexact() to do this your code would look like this. DateTime valor; DateTime.TryParseExact(reader["DATA"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out…
-
4
votes1
answer103
viewsA: Mysql is duplicating search result
You can use the GROUP_CONCAT to group and concatenate your string as follows. select id_tabela1, GROUP_CONCAT(tid_tabela2 SEPARATOR ' ') as tid_tabela2 , GROUP_CONCAT(tid_tabela3 SEPARATOR ' ') as…
mysqlanswered Marco Souza 12,304 -
1
votes1
answer178
viewsA: Disabling Unfilled Textbox
Your code has several serious faults that can cause error at the time of execution, If user type a character other than number you will get a conversion error. Convert.ToInt64(textBox1.Text); Very…
c#answered Marco Souza 12,304 -
6
votes4
answers931
viewsQ: How to verify variables that are not used?
Is there any way to verify which variables are not used within the scope one-class? As in the example below, the variables teste1 and teste4 has no utility within the application, as could locate…
-
3
votes3
answers9343
viewsA: Check if a date is valid
How can you not use the DateTime an exit would be as follows regex to do this. ^([1-9]|([012][0-9])|(3[01]))/([0]{0,1}[1-9]|1[012])/\d\d\d\d [012]{0,1}[0-9]:[0-6][0-9]$ Look in the dotnetfiddle. But…
-
1
votes1
answer763
viewsA: How to return the records between two values with the SQL Server Database?
Just use a subquery to make your filter. The sulução stay like this; declare @CADNOTICIAS table ( CODIGO int, THUMB VARCHAR(10), TITULO VARCHAR(50), TEXTO VARCHAR(100), CATEGORIA VARCHAR(100) )…
-
4
votes2
answers614
viewsA: How to make a Select to not show reset result?
Use a Subselect and filter the result of select internor. select * from ( SELECT COUNT(DISTINCT ROMANEIO) ROMANEIO FROM PCN_ROMANEIO_DISTR_ITEM WHERE USUARIO = 'junior' UNION ALL SELECT…
-
3
votes2
answers24947
viewsA: How to do for loop in SQL SERVER?
sql server does not have the FOR LOOP, instead he use the WHILE , for this you have to create variables as counter. Your code look like this. declare @V_EXTERNO int = 1 declare @V_INTERNO int = 1…
-
6
votes3
answers269
viewsQ: How to search and save a single field?
How can I search a single field of the table change it and save this field without having to search all fields of the table? The reason for this is simple, I have some tables that have more than 30…
-
0
votes4
answers594
viewsA: Return value in SQL Server query
Your major error is in incorrect use of CASE syntax. CASE input_expression WHEN when_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END Don’t give to understand much what…
-
0
votes2
answers441
viewsA: System.Data.Sqlclient.Sqlexception: Conversion failed when Converting the varchar value to int
Your question is not clear, your code is incomplete, not to understand what you have in your proc sp_vm_getUserItems and where you are using your first code that seems to be in the application, but…
-
0
votes3
answers219
viewsA: operation with data sqlserver
The corresponding syntax in SQL SERVER for the stretch CAST(((CAST(SYSDATE-EPL.DAT_FABRICA AS INT)) is DATEDIFF(day, getdate() , EPL.DAT_FABRICA) Your query would look like this. SELECT CASE WHEN…
-
0
votes1
answer723
viewsA: Update in Database by c#
Stick to the parameters you are passing for your method. A good check is you do the select right in the database to see if the data really exists. select * from Login WHERE usuario = equal to the…
-
1
votes1
answer501
viewsA: How to list multiple columns using Inner Join and left Join?
You need to specify the relationship between the two tables in the clause ON, as the example below SELECT dataformat(pd.datacriacao,'%d/%m/%Y') as datacriacao, p.* FROM protocolos p join…
-
0
votes3
answers23959
viewsA: Disable SQL Server Column Identity
You need to temporarily authorize the insertion of identity values, to do so in SQL Server Management Studio right-click on the table and click Design as shown below. After that click on the PK of…
-
3
votes1
answer593
viewsA: How do function to encrypt password in C#?
There are various forms of data encryption out there ( here for example ) and one of them is MD5 (it’s not safe to be an example), which is a 128-bit cryptographic hash (or cryptographic hash)…
-
11
votes2
answers309
viewsQ: What’s the difference between Savechanges and Submitchanges?
Within the context Entity Framework what is the difference between SaveChanges and SubmitChanges? When I should wear one or the other?
-
2
votes2
answers1873
viewsA: How to check if the query did not return data?
If you want to check if your method is returning value, the simplest to do in this case is to use the one if lista == null is a Count() > 0. List<tb_cabecalho> lista =…
-
2
votes1
answer82
viewsA: Download a pdf from a web application to a desktop application, in C#
Your question is too broad........ You can create your web application to upload files to a web server. The second part would be the most appropriate windows service, that would run in the…
-
1
votes3
answers8989
viewsA: What is "build" and what is its relationship to the IDE?
Building is the process of transforming your source text files into one or more files called targets which are used when the application runs. Projects have a single target: an executable file…
-
0
votes1
answer471
viewsA: Doubt with Time Asp.net mvc
Your problem is that your project is Web and you are trying to use a Timer class that has no support for this private static System.Timers.Timer timer; when you should use System.Web.UI.Timer. Your…
-
4
votes1
answer75
viewsA: Sql group records
Try using a subselect. select dt_producao as DT_PROD ,cod_turno as COD_TURNO, cod_periodo as COD_PERIODO, sum(APONTTOTAL) as "APONT.TOTAL", QTENTREGUE as "QT.ENTREGUE"", QTCLASSIFICADO as…
-
1
votes2
answers88
viewsA: Sql Server 2014 Null Value
You will not be able to compare a field value null with the operator =, for that exists the IS NULL that is to say. if (@var is null) set @bool = 1 else set @bool = 0 There is one thing also that…
-
3
votes1
answer3172
viewsA: How to concatenate data into sql server
Would that be. SUADATA between CAST(CONVERT(VARCHAR(10), CAST(getdate() AS DATE), 101) + ' 00:00:01' AS DATETIME) AND CAST(CONVERT(VARCHAR(10), CAST(getdate() AS DATE), 101) + ' 11:59:59'AS…
-
0
votes2
answers97
viewsA: How to bring an item list
Just exchange your Firstordefault for Where. The Firstordefault returns the first object establishing or not a condition, whereas the Where return all objects found in the condition.
-
0
votes1
answer158
viewsA: Doubt with Script to Generate Sql Server 2014 Database Backup
There are two factors that can generate this error. The briefcase Backup_test, does not exist in the same server location where the query is being executed. The user running the query is not allowed…
sql-serveranswered Marco Souza 12,304 -
1
votes1
answer173
viewsA: Addorupdate - use array as parameter
This is because LINQ to Entities requires the entire LINQ expression to be translated into a server query and therefore you cannot call a method from outside, in your case Linq does not reorganize…
-
4
votes1
answer174
viewsA: Sql Server Stored Procedures
If the answer is from a DBA, of course it will say that there is no problem and that should be created procs in the database, if it is a developer working with an ORM, of course it will tell you to…
-
1
votes2
answers9742
viewsA: How to insert current date in postgresql?
If your table already exists you need to update it alter table minha_table alter column minha_date set default current_timestamp If you are creating you can already create the column with the…
-
1
votes1
answer531
viewsA: How to save Image to a specific folder?
You almost got there, to fix just change the shape seguitne protected void btnSalvarDestaque_Click(object sender, EventArgs e) { if (fuFotos.HasFile) { string strname = fuFotos.FileName; string path…