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
1 answer

Why my ADO.NET queries does not run in single execution but they will run in seperate executions?

Regarding a question and its related answer, I'm trying to create a new table type using SQL queries and run a join query on data which are of this table type. I put both queries in the same script, i.e. create type and select but it is not…
VSB
  • 9,825
  • 16
  • 72
  • 145
0
votes
0 answers

Pass two value with two parameters in c# into sqlcommand and read value to disable button?

I am trying to get this method to read values from the database as well as to get values from an asp.net webform. I have tried the code below but never worked public void CheckLikedEvents() { if (User.Identity.IsAuthenticated) …
0
votes
0 answers

Getting error while reading SQLParameter value in VB.NET

Below is my code Dim myCmd As SqlCommand myCmd = New SqlCommand("Update tbl SET Name = @Name, Age=@Age where Id=3", GetConnection()) myCmd.Parameters.AddWithValue("@Name", "Charles") myCmd.Parameters.AddWithValue("@Age", 55) After few lines I want…
captainsac
  • 2,484
  • 3
  • 27
  • 48
0
votes
1 answer

SQL processor runs out of internal resources due to a huge number of partitions created

I have a read query (not a stored procedure) within my Perl script for choosing the latest TestHistoryID value for a Test against the TestID. A Test (or simply a piece of code) runs multiple times as a part of regression process. While the TestID…
0
votes
1 answer

Passing a huge XML string to a stored procedure and parsing it further, use parsed elements as params to call another stored procedure

I am using SQL Server 2016 and want to reuse an existing stored procedure (let's call it ESP) by calling it from a newly-written stored procedure (let's call it NSP). ESP is an atomic procedure that accepts a few parameters (3 integers, 1 varchar…
Tejas
  • 21
  • 5
0
votes
1 answer

SQL Server : Optional Parameter Behavior Logic

I am implementing a stored procedure in SQL Server 2014, with two parameters: @CLIENTID and @CONTRACTID. One of the parameters is optional, so, when the stored procedure receives only the Client ID, it should return all the information related to…
0
votes
1 answer

Using default value for a date parameter in metabase

In metabase I want to have a query that gets two parameters of type date but if they are not provided uses some default values instead. This is an example of a between clause I used to achieve that but failed. It seems when no value is passed as…
Hessam
  • 1,377
  • 1
  • 23
  • 45
0
votes
1 answer

SQL Server : add parameter boolean from vb net into sql as bit

I have a SQL Server database with a table called tblFeatures with 2 columns Feature (Nvarchar(50)) and Setting (bit). I am trying to set the value of this Setting for each Feature via a check box in VB NET. I have tried using True/False 0/1 but have…
Dan
  • 3
  • 2
0
votes
2 answers

How do I get around this common SQL problem

Haven't come across this in ages and when I searched for the solution I couldn't find one. I think its called overloading in SQL. Basically when I have "" (an empty string) for any parameter in this SQL I don't want to set a value in the…
Exitos
  • 29,230
  • 38
  • 123
  • 178
0
votes
0 answers

Assigning DBNull to an integer type throwing an error when using with the ternary operator

I have a this piece of code below where I'm checking if a value in a certain field is blank ("") and if it is I want to set the value of the SqlParameter to NULL otherwise to the value from the field. My original code was as…
psj01
  • 3,075
  • 6
  • 32
  • 63
0
votes
1 answer

ASPX SQL Parameter

I'm trying to make a filtered list based on the user's input and lack of input. I am able to filter if the user has inputted a whole name or just the first character of a name, I have 3 different textboxes (name, surname, country) that's used for…
user4283143
0
votes
1 answer

Having multiple values assigned to a single ADO.Net SqlClient parameter

I wish to run an SQL select statement similar to this SELECT * FROM CatalogueItems WHERE id IN (1,10,15,20); using ADO.Net SqlClient style @name parameters. I've tried using a stored SQL strings SELECT * FROM CatalogueItems WHERE id IN (@Ids) and…
ajmccall
  • 2,024
  • 23
  • 42
0
votes
1 answer

How to set sql parameters

I try that code for use sql parameters but didnt work and didnt return any error. How can I fix it? string sql = "SELECT * FROM "+mw.db_name+".ananmez_genel Where hasta_id='@hastaid'"; string connectionString =…
user8210624
0
votes
2 answers

How to use Column Names from list into MySql insert

I have 2 lists: List ColumnNames = new List(); List ValueNames = new List(); ColumnNames = names.Keys.ToList(); ValueNames = names.Values.ToList(); I'm trying to use this lists into MySql statement: ... MySqlCommand…
0
votes
0 answers

C# SqlParameter properties throw null reference immediately after construction

Consider the following program static void Main(string[] args) { SqlParameter parambe = new SqlParameter("@myParam", "myValue"); Console.ReadKey(); } and observe the result, properties are throwing NullReferenceExceptions! Why is this?…
Matt
  • 1,674
  • 2
  • 16
  • 34