Posts by Marco Souza • 12,304 points
506 posts
-
1
votes1
answer318
viewsA: Save a complex object with Entity Framework
My question is this: the Entity Framework knows how to differentiate an Item New to an Edited Item ? If you create an object Requests new and attach it in context, the Entity Framework will know…
entity-frameworkanswered Marco Souza 12,304 -
1
votes2
answers657
viewsA: How to list NULL on a LEFT JOIN even if it returns joins?
See if that’s it. declare @representantes table ( cod int ) declare @vendedores table ( cod_vendedor int, cod_representante int ) insert into @representantes values (1), (2), (3), (4) insert into…
-
2
votes2
answers609
viewsA: How to use WHERE function in column created from a formula?
Make a subselect, your column State , does not yet exist within the context you are creating, ie it is the composition of the line. IF(SUM(estoque.Estoque_produto) > produtos.estoquemax_produto *…
mysqlanswered Marco Souza 12,304 -
1
votes2
answers84
viewsA: How to list bookings registered by a single administrator? (1:N)
Just use the Where from the Line and pass the id you want. public ActionResult Index() { return View(db.Reservas.Where(n => n.administrador == 1 ).ToList()); }…
c#answered Marco Souza 12,304 -
6
votes2
answers1132
viewsA: Select too slow, how to improve?
Try to create the mysql search indexes. ALTER TABLE municipio ADD INDEX(codigo); ALTER TABLE artesao ADD INDEX(codMunicipio); ALTER TABLE coordenacaomunicipios ADD INDEX(codMunicipio, codCoordenacao…
-
2
votes2
answers454
viewsA: How to convert Float to String using LINQ for Entity?
I was able to solve the problem using two conversions one for Toint64 and one for Tostring. var arquivos = consulta .Select(n => new ListaArquivos { NumeroContrato = n.docsCol.Apolice,…
-
1
votes1
answer38
viewsA: Error when grouping table field
Your mistake is because you are trying to group only one field in your Quey, you would have to use the MAX, MIN, AVG functions a simply group all your query fields. SELECT e.eqp_vch_NmrCnt AS…
-
1
votes2
answers454
viewsQ: How to convert Float to String using LINQ for Entity?
How to convert Float to String using LINQ to Entity? I need to convert a field from my database that has the float type to the string type in my C# using the LINQ. Try using Convert.Tostring,…
-
1
votes1
answer512
viewsA: How to add current record to previous record by creating a cumulative?
I don’t have a lot of time to think of something better right now, but it solves. I hope someone gives a better answer. SELECT DAY(i.imp_data) AS DATA, m.mt_valor / m.mt_valor /…
-
0
votes1
answer1015
viewsA: How to check user on login screen?
Change your method to the below and validate your user protected void btn_Entrar_Click(object sender, EventArgs e) { SqlConnection conexao = new SqlConnection(); conexao.ConnectionString =…
-
17
votes2
answers49607
viewsA: How to format a Datetime field in Brazilian dd/MM/yyyy format?
User the Convert, with the parameters below. select getdate() as datanormal, Convert(varchar(10),getdate(),103) as dataformatada In your case. SELECT e.NmrCnt AS [Contrato] ,e.NmrSerie AS [Serie]…
-
1
votes1
answer837
viewsA: How to add multiple rows of two tables in Mysql
You need to edit your question with more details of your tables, if what other way to do this could be, of course I don’t know what you really filter. It would be interesting for you to see a little…
mysqlanswered Marco Souza 12,304 -
3
votes2
answers184
viewsA: How to use the IN clause in Lambda?
Do something like this. using (var ctx = new stackoverflowEntities()) { var qrInSubCategoria = ctx.Cliente .Where(C => ctx.ErrosProducao_Cliente.Any(EC => EC.CodCliente== C.CodCliente…
-
14
votes3
answers2393
viewsQ: Divergence in encrypting and decrypting in Java and C# Aes algorithm
I have two projects in Java and another in C# where the two communicate with each other, and one of the functions and encrypt and decrypt the confidential information between them, using aes…
-
2
votes1
answer117
viewsQ: How to change Java’s final property to C#?
Which property in C# corresponds to final Java, I need to change my variables final String mensagem = "Tokio Marine Seguradora S.A."; to something corresponding in C#. using System; namespace…
-
2
votes1
answer227
viewsA: List Mysql tables and filter by date
You can start by using the INNER JOIN to join their tables, use the clause WHERE to reference a specific field (specific seller) the clause BETWEEN for a range of dates (extra commission on a range…
mysqlanswered Marco Souza 12,304 -
6
votes2
answers21084
viewsA: Brazilian Time Zone in Mysql
Change the global time zone variable: SET @@global.time_zone = '+3:00'; QUIT The variable time_zone can be adjusted directly in the Mysql client console. Check your current time with the NOW()…
-
1
votes1
answer812
viewsA: How to use CASE WHEN in an IN statement?
You will not get it this way because select returns the elements of select ONE to ONE and not a list of int, what you can do is circumvent its AND clause with two conditions by checking the…
-
1
votes2
answers574
viewsA: Postgresql query without data return
Change your query to; SELECT * FROM venda ve WHERE ve.datavenda::date <= '28/08/2016'
-
1
votes1
answer1545
viewsA: System Error.Indexoutofrangeexception
A Indexoutofrangeexception exception is cast when an invalid index is used to access a member of an array or a collection, or read or write a specific location in a buffer. This exception inherits…
c#answered Marco Souza 12,304 -
1
votes1
answer1013
viewsA: How to do date search through dateTimePicker?
If you use your component dateTimePicker_pesquisar to filter the data by month and day passing one by one separately you can do as the example below. using System; using System.Data; using…
-
2
votes2
answers101
viewsA: How to select a field with MAX()+1 and use in an INSERT?
You can pass your select inside your Insert, $stmt = $this->conn->prepare("INSERT INTO tasks (Project, CompanyFantasy, Priorities, Delivery, Attachment, ByUser, Systems, OrderTask, Subject)…
-
1
votes1
answer166
viewsA: Error ordering Gridview with empty row column
Your question is not clear enough, so I’m going to kick over what might be going on based on your mistake. That is to say, icomparable interface This interface is implemented by types whose values…
-
0
votes2
answers779
viewsA: How to set read-only line of Gridview made with Devexpress?
For the Devexpress Gridview you can use the Gridview.Customrowcelledit Event: //... var repositoryItemTextEditReadOnly = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();…
-
14
votes2
answers1892
viewsA: What is the difference, in practice, between "" and String.Empty?
There is really no difference from the point of view of performance and generated code. In performance tests, they went there and here, among which one was faster against the other, and only by…
-
1
votes1
answer26
viewsA: SQL Server 2012 - Generate query from one table to another involving 3 (three) tables at once
User the INNER JOIN sql. Specifies all matching row pairs returned. Discards the corresponding rows of both tables. When no junction type is specified, this is the default. FULL [ OUTER ] Specifies…
sql-server-2012answered Marco Souza 12,304 -
1
votes2
answers4316
viewsA: Problem to run IIS Express on my network
According to the comments, you can configure the ISS from your local machine to make your application available. See the list below of references to this; references 1 references 2 references 3…
-
0
votes3
answers756
viewsA: How to remove duplicate data in this query?
See if it helps. select products.id as product_id, offers.id as offer_id, companies.id as company_id, products.title, ST_Distance(companies.location, 'POINT(-48.030322 -15.839689)':: geography) /…
-
2
votes3
answers151
viewsA: How to create extension methods in the Entity Framework using Linq?
See the example below of how you can create an extension method as you want. using System; using System.Linq; using System.Web.UI; using System.Web.UI.WebControls; namespace stackoverflow { public…
-
2
votes3
answers7106
viewsA: How to query a date range in mysql?
You can use the expression; SELECT * FROM `table` where STR_TO_DATE(data, "%d/%m/%Y") >= STR_TO_DATE('10/01/2016', "%d/%m/%Y") and STR_TO_DATE(data, "%d/%m/%Y") <= STR_TO_DATE(09/02/2016',…
mysqlanswered Marco Souza 12,304 -
2
votes3
answers15156
viewsA: List all triggers in SQL Server
You can use select below. SELECT sysobjects.name AS trigger_name ,USER_NAME(sysobjects.uid) AS trigger_owner ,s.name AS table_schema ,OBJECT_NAME(parent_obj) AS table_name ,OBJECTPROPERTY( id,…
-
1
votes1
answer466
viewsA: How do you recover data typed in Gridview and then save to the database?
If your intention and recovers the data to be saved in your database after the click on the saved button, you can simply scan your DataGridView and recovers field by field using the Rows Property it…
-
4
votes3
answers960
viewsA: How to find a String from Regular Expressions
For your data sample you can do, change the dynamic table to your actual table, create the fields in your table and try to make the change. You can use a Begin tran and in case it’s all right commit…
-
5
votes2
answers1642
viewsQ: How do you convert an Enum guy into a list?
Is there any way to convert a Enum in List? public enum TiposHospedagem { Casa = 1, Hotel = 2, Pousada = 3, CasaCampo = 4 } I’m trying to run the enum and add to the list, but the foreach does not…
-
2
votes2
answers1494
viewsA: How to get the first result of duplicate lines?
You can use a sub select with top 1 to do this along with the group by do select, select fk_nota_fiscal, fk_produto, valor, campo2, (select top 1 campoXXX from @teste t2 where t2.fk_nota_fiscal =…
sql-serveranswered Marco Souza 12,304 -
2
votes1
answer633
viewsA: Select Returning Null from Database
Your query is wrong in: Usuarios usuarios = (Usuarios) em.createQuery("SELECT nome , senha from usuarios where nome ='"+ nome +"' and senha ='"+ senha+"'") .setParameter("nome",…
-
1
votes2
answers1524
viewsA: Condition on Join or Where?
Exist, and your query can still bring divergent data depending on the fields used in the filters as in the example below (done in sql server) problem I had in that question. declare @tabela1…
-
1
votes1
answer501
viewsA: How to pick up data after a 2 string separators in a select (SQL)?
You can use the function RIGHT that returns the last(s) element(s) of the string and makes a case to check if its character is in the last position. declare @teste table ( dha varchar(20) ) insert…
sqlanswered Marco Souza 12,304 -
2
votes1
answer792
viewsA: How to set the size of an array of bytes dynamically?
The current implementation of System.Array use Int32 for all its internal meters etc, then the theoretical maximum number of elements is Int32.MaxValue. But the . NET framework also has a maximum…
-
12
votes1
answer480
viewsQ: Passing parameters with Asp.Net MVC
In asp.Net MVC. What’s the difference between using ViewBag, ViewData e View Tipada? And when we should use them, there is some specific situation? There is a difference in performance between them?…
-
0
votes1
answer194
viewsQ: How to do a search in an app using Angularjs with correct parameter passage?
How to do a search in an app using Angularjs with parameter passage correctly, when I speak correctly I refer to avoid SQL injection. For example, the parameter var parameters = "joao"; in the query…
-
2
votes1
answer94
viewsA: Oracle SQL Error Invalid Number
You can subtract dates in Oracle. This will give you the difference in days. Multiply by 24 to get hours, and so on. SQL> select oldest - creation from my_table; If your date is stored as…
-
0
votes4
answers156
viewsA: How to avoid repetition in LINQ queries?
If your goal is to return only a few fields from your table you can use Extension methods, to work as if you were using any other Linq method, and you still have the facility to use as many filters…
-
0
votes1
answer142
viewsA: Display the ID of another table in Datagridview
Your question is not clear, but if your intention is to have one more field on your grid and that field is already on your listPessoaFisica, then just change your query with this field, IDPessoa =…
c#answered Marco Souza 12,304 -
1
votes2
answers235
viewsA: Limit 1 line in queries with primary key queries
The clause is unnecessary limit. Mysql provides a limit clause which is used to specify the number of records to be returned. The LIMIT clause makes it easier to encode multiple page results or…
-
2
votes2
answers488
viewsA: Web Paging with C#
You have to use more method o Skip //Mensagens Enviadas List<Mensagem> mensagens = this.mensagemServico.GetMany(l => l.LojaId == loja.LojaId && l.OrigemId != 0).OrderByDescending(l…
-
1
votes1
answer194
viewsA: How to delimit a string field for use in the IN clause
You have to convert your string to a list, for that you would need a FUNCTION to be used within your select. create FUNCTION [dbo].[fnStringList2Table] ( @List varchar(MAX) ) RETURNS @ParsedList…
sql-serveranswered Marco Souza 12,304 -
1
votes1
answer113
viewsA: Entity Framework 6: Removal method does not work
If your goal is to delete, you can change your Remove for Deleteobject Objectcontext.Deleteobject(Entity) marks the entity as deleted in context. (Entitystate is deleted after that.) If you call…
-
1
votes5
answers2439
viewsA: Subtract sums of fields in two separate tables
You can do a JOIN as follows. declare @armazem table(qtdsaco int) declare @armazem2 table( qtdsaco int) insert into @armazem values(112),(3),(432),(22),(1),(5),(4),(3),(2) insert into @armazem2…
-
2
votes1
answer3359
viewsA: Error; Connection has not been closed. Current connection status opens Sqlserver 2016
This is simply because you are trying to open a connection to the bank when it is already open. See the example below. using System; using System.Configuration; using System.Data; using…