I have this error:
Falha ao converter o nvarchar valor 'VINET' para o tipo de dados int.
Below my code:
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = ConfigurationSettings.AppSettings["consBanco"].ToString();
string sql = "SELECT * " +
"FROM Orders WHERE CustomerID = @CustomerIdParam";
dataConnection.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = dataConnection;
cmd.CommandType = CommandType.Text;
//SqlParameter param = new SqlParameter("@CustomerIdParam", SqlDbType.Char, 5);
//param.Value = customerID;
//cmd.Parameters.Add(param);
cmd.Parameters.AddWithValue("@CustomerIdParam", 1);
// cria o dataadapter...
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
// preenche o dataset...
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
grdTeste.DataSource = dataSet;
grdTeste.DataMember = dataSet.Tables[0].TableName;
}
catch (SqlException ex)
{
}
}