executenonquery

ExecuteNonQuery update does not store change

ぐ巨炮叔叔 提交于 2021-01-29 02:08:42
问题 I am trying to update some fields in the database, using ExecuteNonQuery(). When trying to update, i receive no error or warning, and it returns me one affected row count. The thing is, that i can only for the current request, see the change. If i reload the page or go through SMSS, the changes are not shown in the database. Hes a little code. string Sql = "UPDATE AccessUser SET [" + Field + "] = '" + Database.SqlEscapeInjection(Value) + "' WHERE AccessUserID = " + User.ID; Response.Write("

sqlite sqlitecommand ExecuteNonQuery vs ExecuteNonQueryAsync c#

[亡魂溺海] 提交于 2020-06-09 05:25:07
问题 I am using c# sqlite version 3. My application requires saving up to 20 columns of data at 4000Hz. To accomplish this I am using threads that take commands from a queue and periodically write/read to the database. Currently, I am just working on the writing portion and have found that ExecuteNonQueryAsync() and ExecuteNonQuery() have relatively the same execution time which makes no sense to me. My function is as follows: public async Task<int> dumpStorage(string cmdStr) { int r; using

Inserting values into a SQL Server database using ado.net via C#

﹥>﹥吖頭↗ 提交于 2020-01-09 06:50:11
问题 I have created a simple program to insert values into the table [regist] , but I keep getting the error Incorrect syntax near ')' on cmd.ExecuteNonQuery(); : private void button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("Data Source=DELL-PC;initial catalog=AdventureWorks2008R2 ; User ID=sa;Password=sqlpass;Integrated Security=SSPI;"); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.regist (" + " FirstName, Lastname, Username, Password, Age, Gender,Contact, " +

Inserting values into a SQL Server database using ado.net via C#

对着背影说爱祢 提交于 2020-01-09 06:49:47
问题 I have created a simple program to insert values into the table [regist] , but I keep getting the error Incorrect syntax near ')' on cmd.ExecuteNonQuery(); : private void button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("Data Source=DELL-PC;initial catalog=AdventureWorks2008R2 ; User ID=sa;Password=sqlpass;Integrated Security=SSPI;"); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.regist (" + " FirstName, Lastname, Username, Password, Age, Gender,Contact, " +

I am getting an error when I try to update records in my access database

自作多情 提交于 2020-01-05 04:41:17
问题 I have a small program that connects to an access database, and what I am trying to do is update(edit) a selected record via an edit form. When I execute my code, I get this error: System.Data.OleDb.OleDbException was unhandled Message=Syntax error (missing operator) in query expression '5346 S. Eubank blvd'. Source=Microsoft Access Database Engine ErrorCode=-2147217900 Needless to say, it is for the Address field.. Here is my code block: private void saveChangeBtn_Click(object sender,

Row count of a stored procedure from another stored procedure

∥☆過路亽.° 提交于 2020-01-03 13:34:08
问题 I have various stored procedures. I need a stored procedure to execute a stored procedure and then return only the row count (number of returned rows by the called procedure) and I need to receive it in c# code. What's the best way to do this? Situation: I have various stored procedures which is called from c# code. Now for another purpose i need to know the number of rows returned by a procedure (I don't want the returned rows, I just the need the number of rows). I cannot change the stored

c#: ExecuteNonQuery() returns -1

荒凉一梦 提交于 2019-12-30 17:18:27
问题 Ive used this method before to return the amount of rows changed. I am it to run an insert method, the insert runs fine in the stored procedure, but the return value from the ExecuteNonQuery always returns -1. Here is my C# code: int ret = 0; using (SqlConnection conn = new SqlConnection(this.ConnectionString)) { using (SqlCommand cmd = new SqlCommand(QueryName, conn)) { conn.Open(); if (Params != null) cmd.Parameters.AddRange(Params); cmd.CommandType = CommandType.StoredProcedure; ret = cmd

Why ExecuteNonQuery() returning -1 without any exception and without inserting the entry in database?

我的未来我决定 提交于 2019-12-25 05:15:43
问题 I have following function: public Exception createTopic(Topic t) { query = "insert into [DisData].[dbo].[discussions]([title],[description],[usrid],[dateadded],[desid],[likes],[shares],[visit],[replyto],[sno]) values(@title,@des,@uid,@dateadded,@did,@like,@share,@visit,@replyto,@sno)"; try { com = new SqlCommand(query, con); com.Parameters.AddWithValue("@title", t.getTitle()); com.Parameters.AddWithValue("@des", t.getDescription()); com.Parameters.AddWithValue("@uid", t.getUsrID()); com

oracle ExecuteNonQuery freezes on ASP.Net

不羁岁月 提交于 2019-12-24 17:20:05
问题 I am trying to run a non query using a Oracle connection in ASP C# with CLR 4.5. Here is my code: string connectionString = ConfigurationManager.ConnectionStrings["OracleConnectionString1"].ConnectionString; OracleConnection conn = new OracleConnection(connectionString); conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "update SALES_ADVENTUREWORKS2012.SALESORDERDETAIL set UNITPRICEDISCOUNT=0 where ROWGUID='4A399178-C0A0-447E-9973-6AB903B4AECD'";

ExecuteNonQuery() returns -1 always

╄→尐↘猪︶ㄣ 提交于 2019-12-22 02:02:28
问题 I am using a stored procedure to insert some value in table. CREATE PROCEDURE [dbo].[Sp_InsertValue] @Val1 as nvarchar(50) @Val2 as nvarchar(50) as BEGIN IF NOT EXISTS(SELECT * FROM @mytable WHERE ID=@Val1) INSERT INTO @mytable VALUES(@VAL2) END I am using ExecuteNonQuery() to call this stored procedure in ASP.NET using C#. It works fine, no issues, it inserts values if they don't exist. The issue is that cmd.ExecuteNonQuery() always return -1. I expect if a record is inserted, it should