Questions tagged [executenonquery]

executes an SQL statement against the Connection object of a .NET Framework data provider, and returns the number of rows affected.

From MSDN: You can use the ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.

Although the ExecuteNonQuery does not return any rows, any output parameters or return values mapped to parameters are populated with data.

For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1.

243 questions
-3
votes
3 answers

problems with command.ExecuteNonQuery(); when working with databases Please help, for assignment

Here is my code namespace SDD_Single_Project___Michael { public partial class NewUser : Form { private OleDbConnection connection = new OleDbConnection(); public NewUser() { InitializeComponent(); …
whowantsmalk
  • 33
  • 2
  • 9
-4
votes
1 answer

Code Doesn't work. C# Execute Non Query

string conStr = null; SqlCommand cmd; SqlConnection cnn; string sql = null; conStr = "Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=DBMSI;Integrated Security=True"; sql = "insert into CEC_Employee values('"+empid + "','" + name + "','" + fname…
Omesh
  • 45
  • 1
  • 1
  • 7
-4
votes
2 answers

How do I check the number of affected rows on ExecuteNonQuery

I am currently working on a C# project and I am running an insert query while (reader.Read()) { SqlCommand GDR_EnumVoiePublique = new SqlCommand("INSERT INTO…
JHDesigne
  • 3
  • 5
1 2 3
16
17