Click here to Skip to main content
15,917,061 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click
connect.Open()
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM KingdomAnimalia", connect)
sql = "UPDATE KingdomAnimalia SET Genus ='" & txtgenus.Text & "', Family ='" & txtfamily.Text & "', Order ='" & txtorder.Text & "', Class ='" & txtclass.Text & "', Phylum ='" & txtphylum.Text & "', where Species ='" & txtspecies.Text & "'"
cmd = New OleDb.OleDbCommand(sql, connect)
cmd.ExecuteNonQuery()
connect.Close()
MsgBox("Updated")
End Sub
Posted
Comments
Member 11475835 24-Feb-15 8:27am    
Please, i need help.... this is our assignment... :) THANK YOU VERY MUCH!! :)
ZurdoDev 24-Feb-15 8:43am    
Be patient. This is a volunteer site. It's rude to keep asking and yelling.

1 solution

1. Order is a key word so you'll need to put it in []
2. Don't ever write code like this, your code is open to sql injection. Instead change your sql to something like the following:

C#
sql = "UPDATE KingdomAnimals SET Genus = @Genus, Family = @Family... ";
cmd.Parameters.AddWithValue("@Genus", txtgenus.Text);
cmd.Parameters.AddWithValue("@Family", txtfamily.Text);
...
 
Share this answer
 
Comments
Member 11475835 24-Feb-15 8:55am    
thank you very much ... :)
ZurdoDev 24-Feb-15 8:58am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900