I have a program in the c # (Visual Studio) registry that contains a textbox to receive a date. Knowing that SQL writes the date in American format, how can I make the user type the date in Brazilian format and that date can be saved successfully in the bank? In the way I'm doing, the user types the date in Brazilian format, but an error occurs when saving, because SQL is trying to save MM / dd / yyyy. Could someone help me, please? Thanks in advance.
Below the code I'm using:
//Variável que recebe o cast no textbox
var validaDataVenda = DateTime.Parse(txtDataVenda.Text);
var validaDataPagto = DateTime.Parse(txtDataPagamento.Text);
//Comando que insere os dados no banco, recebendo os textboxes como parâmetros
VendaDAO.InsertVenda(novoCodigo.ToString(), txtValor.Text, dataDaVenda.ToString(), dataDoPagamento.ToString(), txtCodigoCliente.SelectedValue.ToString(), txtCodigoProduto.SelectedValue.ToString(), txtQuantidadeRequerida.Text, recebido);
If I insert "31/102016", for example, this error occurs: "Conversion failed when converting date and / or time from character string".