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
5
votes
3 answers

ASP.net user data getting crosses between users accessing objects

This is kind of a weird one. I'm looking for ideas on how to ask the right question as much as I am an actual solution. I've got a website and we just had a huge jump in traffic. Now all of the sudden we're getting sql parameter errors left and…
Birk
  • 2,173
  • 4
  • 21
  • 26
5
votes
3 answers

How to pass default keyword for table valued function call in ADO.NET

So here's the deal. In our database, we wrap most of our reads (i.e. select statements) in table valued functions for purposes of security and modularity. So I've got a TVF which defines one or more optional parameters. I believe having a TVF with…
Mason
  • 137
  • 3
5
votes
4 answers

Return value from OleDbCommand

sqlQuery = "SELECT [ID] from [users] WHERE CallerName=@CallerName"; OleDbConnection conn = new OleDbConnection(connectionString); conn.Open(); cmd = new OleDbCommand(sqlQuery, conn); cmd.CommandText = sqlQuery; cmd.Parameters.Add("@CallerName",…
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177
4
votes
3 answers

Output parameter issue in sql server and c#

Why if I have this stored procedure created with an output parameter, I'm getting the following error: sp_DTS_InsertLSRBatch expects parameter @ErrorMsg which was not supplied Stored procedure code: set ANSI_NULLS ON set QUOTED_IDENTIFIER…
Somebody
  • 2,667
  • 14
  • 60
  • 100
4
votes
2 answers

Can I pass a SqlParameterCollection object into a SQL Command

I currently have a connection class that handles all of my database connectivity. What I am trying to do is build a SqlParameterCollection object on one page, then pass that object to my connection class. Is it possible to do this? I am not getting…
mmk_open
  • 1,005
  • 5
  • 18
  • 27
4
votes
1 answer

SqlParameter(string, object) can't handle constant value

I got a function in which I send two requests to a SQL Server database; on the second request however, I get a SqlException and the parameter @mpe is missing. If I try to set the constant value 0 in the constructor of SqlParameter. protected…
Jens Marchewka
  • 1,372
  • 1
  • 13
  • 22
4
votes
1 answer

No SqlParameter.UdtTypeName on netcoreapp1.1! How to use UDT?

This UdtTypeName property is required to read or write Geography, Geometry or HierarchyId. I can't find any workaround or post/information on this subject. Does anyone have an explanation?
Spi
  • 686
  • 3
  • 18
4
votes
2 answers

Supplying output parameter to sqlparametercollection resulting in error (Varbinary)

I want to supply an output parameter to my stored proc. This output proc is returning byte[]. How do I do this? If I do the following: command.Parameters.Add(new SqlParameter("@Bytes",…
GurdeepS
  • 65,107
  • 109
  • 251
  • 387
4
votes
2 answers

Efficient way of providing SqlDbType?

I have this working code below. However, I there is no SqlParameter constructor that takes name, value, and SqlDbType and I want to just provide the type for the date parameters. Is there a way to do that which does not require adding a lot of code?…
CodenameCain
  • 573
  • 1
  • 9
  • 22
4
votes
4 answers

How to pass correct object value in SqlParameter for datatype bit?

I am trying to pass a bit value only if needed (is checked). How do I do this correctly? I am not getting a change in my dataset. SQL Server 2008. if (chkExpired.Checked) CmdGetDetails.Parameters.Add(new SqlParameter("@isExpired", 1));
JoJo
  • 4,643
  • 9
  • 42
  • 65
4
votes
1 answer

SqlParameter Constructor Integer length issue

I'm currently debugging an SQL query that deletes through C# an item in a SQL server table based on a number of parameters. Currently this statement is failing. One of the parameters supplied is based on a version ID of the item. The SQL parameter…
user1352057
  • 3,162
  • 9
  • 51
  • 117
4
votes
2 answers

Wrong match with LIKE and parameter

I want to compare a string to see if it contains a substring, however, when I use a variable it evaluates to true when it should be false. Any idea why this is happening and how to fix this? DECLARE @Match VARCHAR SET @Match = '%Matching%' SELECT…
Arnoud Kooi
  • 1,588
  • 4
  • 17
  • 25
4
votes
3 answers

How to use SQL parameters to get dataset from SQL Server

I'm working on C# project and I'm new to this technology. I want to read some data from SQL Server 2008, and I write the following code public User select(string username, string password) { string connection =…
Fadi Khalil
  • 291
  • 4
  • 8
  • 18
4
votes
1 answer

How test SqlParameter for equality

Using NUnit and NMock2 I was not able to compare what I thought were the same SqlParameters: SqlParameter param1 = new SqlParameter("@Id", 1); SqlParameter param2 = new SqlParameter("@Id", 1); Assert.IsTrue(param1.Equals(param2)); // This failed I…
sgmeyer
  • 645
  • 5
  • 21
4
votes
1 answer

sqlParameters Array in VB.Net

I'm trying to create a typed-sized parameters array in VB.Net: Dim parameters() As SqlParameter = New SqlParameter() _ { New SqlParameter("@first_name", SqlDbType.VarChar, 50) {Value = "john"}, New…
Fabio Belz
  • 258
  • 2
  • 6
  • 12
1 2
3
21 22