Questions tagged [dbcommand]

38 questions
3
votes
1 answer

Parameter Add Causing Timeout in DBCommand

I have a Parameter add function like bellow: public static void AddParameter(DbCommand comm, string ParamName, Object objValue, DbType Paramtype,int paramSize) { //comm.Parameters.Clear(); DbParameter param = comm.CreateParameter(); …
Mehbube Arman
  • 472
  • 1
  • 7
  • 18
2
votes
1 answer

Loading a SQL script from within another SQL script in H2 database

Is it possible to include sql files within another sql file in H2 database. I have 5 sql files 1) create-tables.sql 2) insert-data.sql 1) data-1.sql 2) data-2.sql 3) data-3.sql In this example i want to include data-1.sql, data-2.sql,…
Pamba
  • 776
  • 1
  • 16
  • 29
2
votes
2 answers

Cannot Pass Parameter in DbCommand in Entity Framework

I have error when I try to pass parameter to stored procedure using DbCommand Error returned: Procedure or function 'Procedure_Name' expects parameter '@TEID', which was not supplied. These are my procedure parameters: @PageNumber INT =…
2
votes
1 answer

Serializing DbCommand with Newtonsoft.Json

I am trying to serialize Entity Framework DbCommand to json with Newtonsoft.Json: public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext interceptionContext) { var path = "C:/result.json"; File.WriteAllText(path,…
jlp
  • 9,800
  • 16
  • 53
  • 74
2
votes
2 answers

Can not bind parameter to CDbCommand

say, i am going to follow the good practice of avoiding sql injection. so this is not good: $query="SELECT id,tag FROM tbl_tags WHERE tag LIKE '%".$tag."%' ORDER BY creation_time DESC LIMIT 0,10 "; in stead i have to use parameter binding: …
1
vote
2 answers

Interception not working as expected with Entity Framework 6

I'm trying to follow the interception example shown here to get it working with EF 6 but running into a problem with the function RewriteFullTextQuery as shown in Figure 1. The interception seems to work but it does not actually execute the logic in…
1
vote
1 answer

.NET ORA-01858: a non-numeric character was found where a numeric was expected

I am trying to construct named parameters but receive an error. Couldn't get data from Database Oracle.DataAccess.Client.OracleException ORA-01858: a non-numeric character was found where a numeric was expected at …
aMerkuri
  • 173
  • 8
0
votes
0 answers

DbCommand.ExecuteScalar() on multiple queries freezes with Sybase

I'm working with a legacy Sybase database, on a table that has an Identity column. When inserting a value into the table, I need to retrieve the new identity value. I've been picking up ideas here and there. Since the database knows neither…
Jean-David Lanz
  • 865
  • 9
  • 18
0
votes
1 answer

Entity Framework Core 3.1 DbCommandInterceptor only logging SELECT queries

I have implemented a DbCommandInterceptor so that I can log the queries which EF is generating. I have added the interceptor to my EF Context within the OnConfiguring method as follows optionsBuilder .UseSqlServer(dbConnectionString) …
PaulAdvancedUk
  • 153
  • 2
  • 10
0
votes
0 answers

Timeout Error Sql Exception 0 x 80131904 .Net Core

I'm using .NET Core and trying to figure out why the SQL Server localdb is not working. I am using Dapper to connect to the database and I used breakpoints to check if all the data was there and it was. I get this error when trying to call the…
Jamar P
  • 11
  • 1
  • 5
0
votes
0 answers

DbCommand.ExecuteNonQuery hangs indefinitely

I was trying to run an insert query on table in my Oracle database. below is the test i'm doing. First lock the table on which i want to do an insert from a SQL Developer session lock table RANDOM_TABLE in exclusive mode nowait Try running an…
Tulasiram
  • 71
  • 8
0
votes
2 answers

dbCommand and stored procedure parameters name different but value is passed. Why?

I use C# and I instantiate a DbCommand in order to execute an Oracle stored procedure. My question is: why does the procedure receive the value through a different named parameter than the on in db? When I add a parameter to the…
Zirbo Filip
  • 300
  • 1
  • 13
0
votes
1 answer

AddInParameter and NULL?

I have problems inserting a null paramater with the AddInParameter method. cmd.AddInParameter(someString, someValueWhichCanBeNULL) As soon as the 2nd param is null, it fails. I also Tried DBNull.Value, fails too. Ideas? The message is:…
grady
  • 12,281
  • 28
  • 71
  • 110
0
votes
1 answer

DBCommand using block

I have the following code: using (MySqlConnection conn = new MySqlConnection(connStr)) { conn.Open(); cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM Events"; cmd.CommandType = CommandType.Text; …
0
votes
1 answer

DbCommand.ExecuteNonQuery error handling

When I use the DbCommand.ExecuteNonQuery() in .net, it will return a scalar. Is that the only information I will get from this command? Or is there also an exception, if for example the command is wrong, or there is a timeout or something else?
DanielG
  • 1,217
  • 1
  • 16
  • 37