Hi Folks, please help me with that please, I'm not figuring out what is going on.
Here is my code.
using System;
using System.Data.SqlClient;
using System.Globalization;
using System.Collections.Generic;
namespace ConexaoBD
{
class Program
{
static void Main(string[] args)
{
CultureInfo provider = CultureInfo.InvariantCulture;
provider = new CultureInfo("pt-BR");
DateTime datahoje;
SqlConnection connection = new SqlConnection(@"data source=DESKTOP-3O98051; Integrated Security=SSPI; Initial Catalog=FastCashFlow");
connection.Open();
/* string strUpdate = "Update Users Set UserName = 'Amarildo' Where UserID = 1";
SqlCommand cmdUpdate = new SqlCommand(strUpdate, connection);
cmdUpdate.ExecuteNonQuery(); */
/* string strDelete = "Delete from Users Where UserID = 1";
SqlCommand cmdDelete = new SqlCommand(strDelete, connection);
cmdDelete.ExecuteNonQuery(); */
Console.Write("Digite o Nome do Usuário: ");
string nome = Console.ReadLine();
Console.Write("Digite o E-mail do Usuário: ");
string email = Console.ReadLine();
Console.Write("Digite o Login do Usuário: ");
string Login = Console.ReadLine();
Console.Write("Digite a senha do Usuário :");
string senha = Console.ReadLine();
Console.Write("Digite a data de cadastro: ");
string datacadastro1 = Console.ReadLine();
DateTime datacadastro = Convert.ToDateTime(datacadastro1);
datahoje = DateTime.ParseExact(datacadastro.ToString(), "dd/MM/yyyy HH:mm", provider);
string strInsert = String.Format("Insert INTO Users(UserName, UserEmail, UserLogin, UserPassword, Date) VALUES('{0}','{1}','{2}','{3}','{4}')", nome, email, Login, senha, datahoje);
SqlCommand cmdInsert = new SqlCommand(strInsert, connection);
cmdInsert.ExecuteNonQuery();
string strSelectusers = "Select * from Users";
SqlCommand cmdSelect = new SqlCommand(strSelectusers, connection);
SqlDataReader reader = cmdSelect.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("Id: {0}, Nome: {1}, E-mail: {2}, Login: {3}, Senha: {4}, Data: {5}", reader["UserID"], reader["UserName"], reader["UserEmail"], reader["UserLogin"], reader["UserPassword"], reader["Date"]);
}
}
}
}
Thanks and best regards.