ExecuteNonQuery with DeleteCommand?

I need use ExecuteNonQuery at those syntax's below? And they are correct? Objective use the da.DeleteCommand; which syntax's I gain performance?

MySqlCommand cmd = new MySqlCommand("DELETE FROM users_login WHERE UserID = @UserID;", coon);
cmd.Parameters.Add("@UserID", MySqlDbType.Int16).Value = oUsuario.UserID;

MySqlDataAdapter da = new MySqlDataAdapter();
da.DeleteCommand = cmd;

coon.Open();
ok = true;

/**OR use this**/

MySqlCommand cmd = new MySqlCommand("DELETE FROM users_login WHERE UserID = @UserID;", coon);
cmd.Parameters.Add("@UserID", MySqlDbType.Int16).Value = oUsuario.UserID;

coon.Open();
cmd.ExecuteNonQuery();
ok = true;

Answers


Yes, if you're executing a DELETE statement, ExecuteNonQuery() on your MySqlCommand instance is what you want to use. It's also what you'd use if you're executing an INSERT or UPDATE statement or a stored procedure that doesn't return a resultset.


Need Your Help

a way to list elements by name, html, php

php mysql html inventory

I'm creating a small car dealership website, and on my inventory page I need to be able to list all the cars I have , and a way to narrow them down.

Parse error: syntax error, unexpected '=' in *.php on line?

php

Every thing is OK.but i can not find why Parse error

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.