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
0
votes
0 answers

Getting an exception: Check the manual that corresponds to your MySQL server version for the right syntax

I am getting MySqlException error while updating the values in database. Values are picking correctly, whereas ExecuteNonQuery() not functioning properly. The exceptionis: "Check the manual that corresponds to your MySQL server version for the…
Karthik
  • 29
  • 5
0
votes
1 answer

ExecuteNonQuery inside of Reader

How can I solve this problem? I do not want to use two connections. ExecuteNonQuery only works if reader is closed. oleCnn = New System.Data.OleDb.OleDbConnection oleCnn.ConnectionString = ConnectionString oleCmm = New…
0
votes
2 answers

getting error at 'ExecuteNonQuery'

The error is 'Sqlexception was unhanded ' There was an error parsing the query. [ Token line number = 1,Token line offset = 8,Token in error = * ] Dim con As SqlCeConnection = New SqlCeConnection("Data Source = C:\Users\vineet\Documents\Visual…
0
votes
2 answers

ExecuteNonQuery Response

I'm writing a small app that will be used to deploy stored procedure updates/releases across a number of servers. I need to report back that the update on each server was successful. At present I'm simply doing the following: int response = …
JIbber4568
  • 839
  • 4
  • 16
  • 33
0
votes
1 answer

Cannot display query results using cmd.ExecuteNonQuery in C#

I have a lotto draw method which should find the winning ticket from the database of purchased tickets. But I am not able to display the results from the query. (I know this isn't how the Lotto really works, I'll come to randomizing the numbers…
PriceCheaperton
  • 5,071
  • 17
  • 52
  • 94
0
votes
1 answer

VB.NET and SQL INSERT INTO; data is truncated

I use VB.NET Studio Express 2012 to read a filestream into SQL Server Express. The database and table are created fine, most records load without error using .ExecuteNonQuery INSERT INTO, but some records I get the error: String or binary data…
user2488689
  • 61
  • 1
  • 2
0
votes
3 answers

textbox data to database, error

Can anyone cast some light on my problem? I have this form code and which is supposed to take the text of the textbox and put it in the database. I am, however, getting an error, SqlException was unhandled by user code: String or binary data would…
DarkVader
  • 41
  • 1
  • 6
0
votes
5 answers

.ExecuteNonQuery() sql asp.net error

This is my first time working with sql and asp.net. I am working on a few examples to ensure I have all the basics I need. I was walking though a tutorial and where everything should be working just fine, I am getting an .ExecuteNonQuery() Error. …
Sean Robbins
  • 71
  • 2
  • 5
  • 12
0
votes
1 answer

SPROC insert with ExecuteNonQuery and ExecuteScalar

SQL insert issue. Running a stored procedure to insert rows to a table and returning the ID created. WHen I run it like this and have an output parameter @ID and use ExecuteNonQuery() it returns -1 for my int idinserted but does give me back the ID…
Jt2ouan
  • 1,964
  • 9
  • 33
  • 55
0
votes
1 answer

OleDbConnection Connection Error

I wrote these code block: ConnectDB.getConStr(); string query = "insert into users (memberName,memberSurname,memberEmail,userName,userPassword) values(@mn,@msn,@me,@un,@up)"; OleDbCommand cmd = new OleDbCommand(…
Ahmet Güzel
  • 95
  • 1
  • 9
0
votes
1 answer

how to change a sql timeout after command has been started

Question: Is there a way to stop the Command.ExecuteNonQuery() before it is completed, without using timeout? I have created a multi-threaded MySQL program that stores and run sql statements. Allowing a group of transactions run at the same time…
0
votes
3 answers

ExecuteNonQuery: Connection property has not been initialized

I've searched for my question here, but I couldn't find it. I am using Microsoft VS 2010 C#. Here is my code: private OleDbConnection myCon; public Form5() { myCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data…
Tham JunKai
  • 259
  • 2
  • 4
  • 11
0
votes
0 answers

SqlCommand.ExecuteNonQuery Method vs Rollback transaction

In code bellow the rollback occurs for sure, but the method ExecuteNonQuery doesn´t return -1 has expected. Any ideas why? using (var connection = new SqlConnection("")) { connection.Open(); var cmd = connection.CreateCommand(); …
0
votes
2 answers

SqlParameter and ExecuteNonQuery causing unrepeatable time outs

I recently inherited some code that is having occasional time-out issues. I am mostly familiar with ORM's, so I am having trouble determining if anything is wrong in this code. When it does not time out, it works in a couple of seconds. Time-outs…
PFranchise
  • 6,642
  • 11
  • 56
  • 73
0
votes
2 answers

(local) SQL Server Running very Slow vb.net programming/debugging why so slow? Executenonquery hangs regular office computer

I am running a local SQL Sever instance on my machine as (local). i am using a regular desktop office computer (i5-2400 @ 3.1 ghz 2.85 gb ram). sqlserver.exe uses 1.5GB of memory in my task manager. I have started to use the sql server instance on…
user1538419
  • 1
  • 1
  • 2