Click here to Skip to main content
15,891,828 members

Comments by Rodrigo Mendes 2022 (Top 7 by date)

Rodrigo Mendes 2022 27-Sep-22 9:24am View    
sorry for the delay in answering, the problem was in SSMS that the data type was not changing
thanks
Rodrigo Mendes 2022 27-Sep-22 6:59am View    
Now the error is this System.Data.SqlClient.SqlException: 'Conversion failed when converting the varchar value '@Disco' to data type int.'
Rodrigo Mendes 2022 27-Sep-22 6:13am View    
Thanks again for the reply, I checked SSMS and and made the changes now it shows this error:
System.Data.SqlClient.SqlException: 'Invalid column name 'Utilizador'.'
Rodrigo Mendes 2022 27-Sep-22 5:37am View    
private void button1_Click(object sender, EventArgs e)

{
SqlConnection con = new SqlConnection("Data Source=OPCOSQL\\OPCOSQL;Initial Catalog=OPCO-SQL;Integrated Security=True;Pooling=False");
con.Open();
SqlCommand cmd = new SqlCommand("insert into [Table] ([Utilizador], [Nome], [Disco], [Processador], [Memória], [Tipo], [Localização]) values (@Utilizador, @Nome, @Disco, @Processador, @Memória, @Tipo, @Localização)", con);
cmd.Parameters.AddWithValue("@Utilizador", textBox1.Text);
cmd.Parameters.AddWithValue("@Nome", textBox2.Text);
cmd.Parameters.AddWithValue("@Disco", textBox3.Text);
cmd.Parameters.AddWithValue("@Processador", textBox4.Text);
cmd.Parameters.AddWithValue("@Memória", textBox5.Text);
cmd.Parameters.AddWithValue("@Tipo", textBox6.Text);
cmd.Parameters.AddWithValue("@Localização", textBox7.Text);
cmd.ExecuteNonQuery();
con.Close();
}
Rodrigo Mendes 2022 27-Sep-22 5:15am View    
Thanks for the answer, but it didn't work and I still get the error