SQL gets Double with "Comma" tab instead of "Dot"

Asked

Viewed 78 times

0

I am developing an ASP.NET application where I need to take a DOBULE typed by the user and pass to the bank.

However there is a divergence of information, the DOUBLE of my bank receives separator with Comma "123,456" and the application passes with Point "123,456", but when the bank receives "." it ignores, so it turns a value "123.456" into "123456"

How can I fix it?

MODEL:

public class Friend
{
    public int Id { get; set; }

    public string Nome { get; set; }
    public string Rua { get; set; }
    public string Cidade { get; set; }
    public string Estado { get; set; }
    public string Pais { get; set; }
    [Required]
    public double Latitude { get; set; }
    [Required]
    public double Longitude { get; set; }

}

Migration:

migrationBuilder.CreateTable(
            name: "Friend",
            columns: table => new
            {
                Id = table.Column<int>(nullable: false)
                    .Annotation("SqlServer:Identity", "1, 1"),
                Nome = table.Column<string>(nullable: true),
                Rua = table.Column<string>(nullable: true),
                Cidade = table.Column<string>(nullable: true),
                Estado = table.Column<string>(nullable: true),
                Pais = table.Column<string>(nullable: true),
                Latitude = table.Column<double>(nullable: false),
                Longitude = table.Column<double>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_Friend", x => x.Id);
            });

Prints:

Print

  • how your bank is configured.

  • Hello, I don’t know much so I don’t know how to answer you right, But since I didn’t touch any configuration after I installed it, I believe it’s Default

  • So you have to check the default of the database and the default of the application this has to be the same, we usually configure en in the application and it sends the data correctly to the database, but, this all depends if it is configured, it is a very local problem

  • Okay, you can tell me where I change it?

  • This one is in the validation that has to be replaced "." by "," is in the jQuery package. because I do not have in hands more by seeing the bank is recording correctly, it is problem on the same front

  • The bank shouldn’t record with "." instead of ","?

  • The bank when it is well configured yes, is usually in the American layout, but, has to configure in several ways. As it runs away from us have to check how it was installed and configured.

  • I looked for some Jquery validation that could reference "." /"," from Double, but unfortunately I couldn’t find anything :/

Show 3 more comments

1 answer

0

In that case you have some options:

  1. You can change your application by placing a Mask in the Text Field just accepting the '.'
  2. You can in the controller of your application add a parse to replace ',' with '.' in your ex variable:

double.Parse("3,5", CultureInfo.InvariantCulture)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.