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

my output parameters are always null when i use BeginExecuteNonQuery

I have a stored procedure that returns a varchar(160) as an output parameter of a stored procedure. Everything works fine when i use ExecuteNonQuery, i always get back the expected value. However, once i switch to use BeginExecuteNonQuery, i get a…
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157
2
votes
1 answer

ora-01036 illegal variable name/number ExecuteNonQuery call usingVB.Net

I'm having an issue executing an Oracle query via .NET. I'm quite new to calling Oracle commands from .Net, (i'm coming from a mySQL background) so any help is much appreciated! I first build a query string... declare pDate date; pErrorCode…
Michael B
  • 109
  • 2
  • 13
2
votes
2 answers

C# ExecuteNonQuery "Connection must be valid and open."

I'm trying to add values into database, but every time I try to add some thing i get an error in the ExecuteNonQuery() with the message "Connection must be valid and open." And I don't know what to do!!! using System; using…
Bordotti
  • 103
  • 1
  • 1
  • 8
2
votes
2 answers

Oracle ExecuteNonQuery hangs on "Select for update nowait"

I've been stuck on this for a few days now, and still can't figure out why : I need to update a record in my Oracle database, before executing the Update query, I want to lock the data with a "SELECT x FOR UPDATE NOWAIT", but when calling the…
JuFra
  • 173
  • 3
  • 11
2
votes
3 answers

Know if a record was just inserted via C# 4.0?

Is it possible in C# / ASP.NET to know if the ExecuteNonQuery inserted a record or not? I am checking to make sure the email address does not exist in the table using a subquery. Is there a way to know if an Insert was made in…
JoJo
  • 4,643
  • 9
  • 42
  • 65
2
votes
2 answers

SQLite-net throwing exception on second call to ExecuteNonQuery

I am using SQLite-net for accessing an SQLite database file in a WinRT app. I don't have any problems reading from the database using the ExecuteQuery (I actually use the modified version from https://github.com/praeclarum/sqlite-net/issues/82 as I…
2
votes
1 answer

SqlCommand ExecuteNonQuery throws OutOfMemoryException

I have problem with executing Sql that in fact is simple call of stored procedure on SqlServer. Consider below Sql Stored Procedure: CREATE PROCEDURE InfiniteLoop AS BEGIN DECLARE @ixi NUMERIC(38) = 0 DECLARE @i…
pjozwiak
  • 71
  • 1
  • 8
2
votes
3 answers

Update Command Executenonquery - Syntax Error

I tried to update some data in C# I got "Incorrect syntax near ')'." in line "da.UpdateCommand.ExecuteNonQuery();". I browsed code a lot of time, and I can't see error anymore. So in my opinion should be OK, but isn't. Could you look at below…
Foee
  • 77
  • 1
  • 5
2
votes
4 answers

How can I insert more than 8000 characters in a VARCHAR(MAX) column with ExecuteNonQuery?

I am trying to insert > 8000 characters (submit from a web page) via ExecuteNonQuery (and DatabaseFactory.CreateDatabase() from MS Practices Enterprise Library). The stored procedure defines the parameter as VARCHAR(MAX). The column is VARCHAR(MAX).…
2
votes
0 answers

VARCHAR(MAX) and > 8000 bytes / ExecuteNonQuery

Possible Duplicate: VARCHAR(MAX) and > 8000 bytes / ExecuteNonQuery (repost) I am trying to insert > 8000 characters (submit from a web page) via ExecuteNonQuery. The stored procedure defines the parameter as VARCHAR(MAX). The column is…
2
votes
2 answers

ExecuteNonQuery leaves a sleeping awaiting command session

I have a command-line utility written in C#, which updates some records in the database and then enters a loop checking some other stuff. For some reason, the SQL execution always leaves a sleeping awaiting command session in SQL server 2008 after…
Tuzki
  • 63
  • 3
  • 7
2
votes
3 answers

ExecuteNonQuery Result in C#

How can i know if i create a database successfully? I am using "CREATE DATABASE DemoDB" as a SQL command. ExecuteNonQuery() method returns 0. What should i use to understand if i created a database successfully?
sanchop22
  • 2,729
  • 12
  • 43
  • 66
2
votes
4 answers

SqLite C# extremely slow on update

I'm really struggling to iron out this issue. When I use the following code to update my database for large numbers of records it runs extremely slow. I've got 500,000 records to update which takes nearly an hour. During this operation, the journal…
user1395659
  • 95
  • 1
  • 2
  • 5
1
vote
0 answers

Can't insert into database by using ExecuteNonQuery() and stored procedure

Language: C# Skill: Beginner Tool: Visual Studio 2010 Hello StackOverflow, I have made a stored procedure for inserting data into a table... Stored proc works fine when I execute it in Server Explorer and it inserts into that table... But when I…
DayTimeCoder
  • 4,294
  • 5
  • 38
  • 61
1
vote
1 answer

Returning scope identity using sqlCommand.ExecuteNonQuery()

I have a stored procedure that looks like so. ALTER PROCEDURE dbo.addPackage( @PackageStatus VARCHAR(50) = null, @OrgCode VARCHAR(50) = null, @SystemID …
gsirianni
  • 1,334
  • 2
  • 18
  • 35