When I run a project in Visual Studio it has the following error:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Logar
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string conexao = "Data Source=(local);Initial Catalog=Cadastro;User ID=sa;Password=m4st3r!";
SqlConnection add = new SqlConnection(conexao);
SqlCommand comado = new SqlCommand("select count (*) Usuario where Usuario =@user and Senha=@senha", add);
comado.Parameters.Add("@user", SqlDbType.VarChar).Value = textBox1.Text;
comado.Parameters.Add("@senha", SqlDbType.VarChar).Value = textBox2.Text;
add.Open();
int i = (int) comado.ExecuteScalar();
if (i > 0)
{
MessageBox.Show("Login e senha encontrado");
}
else
{
MessageBox.Show("Erro");
}
add.Close();
}
}
}
What error is this?