Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to add data in mysql table by pressing the button of vb.net pls tell me the coding of that button
Posted
Updated 8-Oct-17 1:07am

 
Share this answer
 
Comments
anand4886 4-Apr-12 14:37pm    
Dim cmd As New MySqlCommand

cmd .CommandText = "Insert Into try (Name) values ("Simon")"
cmd.CommandType = CommandType.Text
cmd.Connection = cn

cn.Open()

cmd.ExecuteNonQuery()

cn.Close()
but in cmd.commondtext line .net is showing an error that "end of statement expected",pls correct my code
Bert Mitton 5-Apr-12 11:06am    
try cmd.CommandText = "Insert Into try (Name) values ('Simon')"

You want to use single quotes (apostrophes), not double quotes when entering your data.
Manoj Kumar Choubey 5-Apr-12 0:27am    
try is keyword (try ---- catch )
check with following query
cmd.CommandText = "Insert Into [try](Name) values("Simon")"
Try:
Using con As New MySqlConnection(strConnect)
	con.Open()
	Using com As New MySqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con)
		com.Parameters.AddWithValue("@C1", myValueForColumn1)
		com.Parameters.AddWithValue("@C2", myValueForColumn2)
		com.ExecuteNonQuery()
	End Using
End Using
 
Share this answer
 

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