ok i need help with this code i more than triple checked the spelling so i dont know what is wrong anymore and i have checked that i inserted the right data also.
This is my code i use to insert into my DB when i break it i get the error "Column name or number of supplied values does not match table definition." what does this mean coz everything in my table is exactly the same
Try
sqlcon.Open()
Dim sql As String = "INSERT INTO hero VALUES(@heroName, @heroStrenght, @heroAgility, @heroIntelligence, @heroAffilLiation, @heroDamage, @heroArmor, @heroMoveSpeed, @heroAttackRange, @heroMissleSpeed, @heroSightRange, @heroSkill1, @heroSkill2, @heroSkill3, @heroSkill4, @heroPicture)"
Dim cmd As New SqlCommand(sql, sqlcon)
cmd.Parameters.AddWithValue("@heroName", txtHeroName.Text)
cmd.Parameters.AddWithValue("@heroStrenght", txtStrength.Text)
cmd.Parameters.AddWithValue("@heroAgility", txtAgility.Text)
cmd.Parameters.AddWithValue("@heroIntelligence", txtINtelli.Text)
cmd.Parameters.AddWithValue("@heroAffilLiation", txtAff.Text)
cmd.Parameters.AddWithValue("@heroDamage", txtDamage.Text)
cmd.Parameters.AddWithValue("@heroArmor", txtArmor.Text)
cmd.Parameters.AddWithValue("@heroMoveSpeed", txtMS.Text)
cmd.Parameters.AddWithValue("@heroAttackRange", txtAR.Text)
cmd.Parameters.AddWithValue("@heroMissleSpeed", txtMissileS.Text)
cmd.Parameters.AddWithValue("@heroSightRange", txtSR.Text)
cmd.Parameters.AddWithValue("@heroSkill1", txtSkill1.Text)
cmd.Parameters.AddWithValue("@heroSkill2", txtSkill2.Text)
cmd.Parameters.AddWithValue("@heroSkill3", txtSkill3.Text)
cmd.Parameters.AddWithValue("@heroSkill4", txtSkill4.Text)
Dim ms As New MemoryStream()
pbHero.BackgroundImage.Save(ms, pbHero.BackgroundImage.RawFormat)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@heroPicture", SqlDbType.Image)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully added", "SAVED", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("An error occured during saving", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
sqlcon.Close()