Questions tagged [sqlparameter]

a .NET class for representing SQL parameters in SqlCommands

SqlParameter is a noninheritable .NET class in the System.Data.SqlClient namespace whose instances represent a parameter for a SqlCommand.

319 questions
0
votes
3 answers

using sqlcommand with multiple ids

So this works great: select name from users where id = @id However, that only selects 1 guy. Say I have 3 IDs instead, normally the SQL would look something like this (without using parameters) select name from users where id in (4,6,9) However,…
Hejner
  • 372
  • 3
  • 15
0
votes
1 answer

Declare the length of a MSSQL output parameter called from C#

I have a mssql store procedure with two parameters input, output. CREATE PROCEDURE SP_Test1 @Pi_Action INT, @Pv_ErrorMessage VARCHAR(250) OUTPUT I am executing this procedure from my application in this way. DbManager…
NestorInc
  • 99
  • 1
  • 12
0
votes
1 answer

how to late parameter bind to dynamic sql statement in a stored procedure

I am attempting to dynamically build a T-SQL statement based on a FieldMapping table and some business rules. Cut the long story short, I have a function that will return the SQL statement as a varchar(max) that I will execute as EXEC (@Sql) in my…
Sash
  • 1,134
  • 11
  • 23
0
votes
1 answer

SqlCommand ExecuteNonquery strange exception

I want to insert a record to SQL Server Database but I got a strange exception while ExecuteNonQuery() process. I got this exception: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed. However my…
cihadakt
  • 3,054
  • 11
  • 37
  • 59
0
votes
1 answer

Create Data.SqlClient.SqlParameter with a SqlDataType, Size AND Value inline?

I have a function which can take a number of SqlParameter objects: Public Shared Function RunSQL(sqlInput As String, Optional params As Data.SqlClient.SqlParameter() = Nothing) As String The aim is basically being able to call the function and…
Interminable
  • 1,338
  • 3
  • 21
  • 52
0
votes
4 answers

Getting timeout errors with SqlTransaction on same table

public TransImport() { ConnString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString; SqlConnection conn_new; SqlCommand command_serial_new; SqlConnection conn; SqlCommand command_serial; …
Anirudh
  • 581
  • 5
  • 14
  • 32
0
votes
0 answers

Float SQLParameters, decimal separator and regional settings

I use a SQLDataAdapter to select/update/insert data from/to a table in MS SQL Server (.NET Framework 4.0 as client framework). The UpdateCommand in the SQLDataAdapter needs 2 float parameters, which I add like this: With…
user1737538
  • 497
  • 2
  • 7
  • 16
0
votes
1 answer

Passing array of raw(32) argument to Oracle Stored Procedure in ODP.NET

I have a custom type and stored procedure defined as follows: CREATE OR REPLACE TYPE GuidArray is varray(1000) of RAW(32); / CREATE OR REPLACE PROCEDURE BulkInsertTempItemGuid ( ItemGuidList IN GuidArray default null ) AS BEGIN -- --…
Stealth Rabbi
  • 10,156
  • 22
  • 100
  • 176
0
votes
1 answer

Going from an SqlParameter to the SQL type

I have an SqlParameter object and I want to get the equivalent sql for the data type, e.g. varchar(50), int, decimal(1, 2) I've started looking at building it dynamically by switching on the SqlDbType to determine if i need to use the Size property…
George Duckett
  • 31,770
  • 9
  • 95
  • 162
0
votes
0 answers

Vb.net sqlconnections parameters don't respect lower case or upper case letters

Why don't the parameters respect lower case or upper case letters? If I put 'Londres' or 'lONDRES' in any parameter then the result is always the same (I used that to login and password). I did use SQL CE 3.5 with [Case Sensitive} on True, but it…
0
votes
1 answer

sqlParameterCollection error

I have a definiton of procedure public int Add_Nastavenie(out int typNastav, int nastavID, string hod) { ResetParameters(); cmd.CommandText = "add_Nastav"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter sqlParameter; …
John
  • 111
  • 1
  • 3
  • 12
0
votes
2 answers

can't get output parameters from a SqlParameter inside a query

I'm doing a simple INSERT query into my database. The column id have auto-generated ID and i need it for another query. I read i can get the generated id using a parameter in output direction, so i wrote this code: string id; queryString = "INSERT…
HypeZ
  • 4,017
  • 3
  • 19
  • 34
0
votes
1 answer

Delete multiple rows in Entity Framework

I am trying to delete multiple rows in EF5 and I'm using the following code sample string TestId = "12,23"; Context.Database.ExecuteSqlCommand("DELETE FROM TEST WHERE TESTID IN (@Params)", new SqlParameter("Params", TestId)); How do I pass…
Peru
  • 2,871
  • 5
  • 37
  • 66
0
votes
3 answers

SQL Parameters - where does expansion happens

I'm getting a little confused about using parameters with SQL queries, and seeing some things that I can't immediately explain, so I'm just after some background info at this point. First, is there a standard format for parameter names in queries,…
Roddy
  • 66,617
  • 42
  • 165
  • 277
0
votes
2 answers

SELECT query using SqlParameter isn't working

I'm working on a select query for sql in c#. Trying to use SqlParameter, but when I debug, I throw an exception: Must declare scalar variable "@p1". I'm passing values in via textbox to properties in a class Customer. This is what is in my event…
will
  • 837
  • 3
  • 11
  • 24