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

SQL Parameter And int Value

I use a query in ado.net to read the information to be displayed in the datagrid, but the problem is that my SQL parameter, which is related to Teacher_Id, has a problem and does not allow the information to be displayed. What is your solution? I…
Saber
  • 27
  • 7
0
votes
1 answer

How to access columns and data of a Sql parameter of SqlDbType as Structured in C#?

In C#, for Table-valued parameter I add a SqlParameter with 'SqlDbType' as 'Structured' and 'Value' as a C# DataTable. I want to extract this data later in my code. I want to verify if the SqlDbType/DbType is 'Structured'. If yes, and if the…
0
votes
1 answer

Stored procedures to insert and then update the table based on identity column

I have a use case where I need to create 2 stored procedures (Insert data, update records) for Audit Table. First SP inserts 6 out of 12 columns of data into the table and auto generates an ID that I need to return and store in a variable in Azure…
0
votes
2 answers

Is it possible to use SqlParameter in in a Transact-SQL query that uses local variables?

Let's say that I have a transact-SQL query that does something like this: INSERT INTO Table1 -- Table1 has an identity column for the primary key ( Table1Value1, Table1Value2 ) VALUES ( @Table1Value1, -- SqlParameter @Table1Value2 --…
Jim Berg
  • 609
  • 4
  • 7
0
votes
0 answers

Make a SQL Parameter char(7) in VB.net

I have the following code: Dim oPNParam As IDbDataParameter = oCmd.CreateParameter() oPNParam.ParameterName = "@PartNumber" oPNParam.DbType = DbType.String oPNParam.Value = PartID …
Mark W
  • 2,791
  • 1
  • 21
  • 44
0
votes
5 answers

SQLServer INSERT getdate() function using parameters

What is the preferred method of adding the current date/time into an SQL Server table with INSERT Command and executenonquery? I'm expecting something like ... cmd.Parameters.Add("@theDate", SqlDbType.VarChar, 20) …
elbillaf
  • 1,952
  • 10
  • 37
  • 73
0
votes
2 answers

Issues on loop for retrieve the dynamic sql parameter values from dynamic textboxes

all. I am a new VB.NET beginner. I am facing the issue of how to pass the dynamic SQL parameter values from the dynamic textboxes to search the data. I had added control of dynamic textboxes and labels and would like to search the data on the…
alice teh
  • 5
  • 4
0
votes
0 answers

Declare variable in SQL with Entity Framework Core for ExecuteSqlCommand()

On my DB I have a star schema implemented which will be updated regulary with new, additional data. In order to achieve that I need to update my dimension tables first. From merge tables I check whether there are values in a specific column which…
TheT
  • 37
  • 7
0
votes
0 answers

Create table where name contains a variable

It there a way to create a table in SQL Server 2016 containing a variable in the name without using code like this? SET @SQL = 'Create table dbo.tblTest_' + @table + ' ...' EXEC @SQL We have existing stored procedures where we create tons of temp…
MChalut
  • 57
  • 6
0
votes
1 answer

Cannot insert the value NULL into column 'SchoolID', table 'TDC.dbo.SWprjectPart' which is dependent dropdownlist

Hi I hope got my problem solved ... I have a listview which contains 2 dropdownlists, it works well in show data but when insert button clicked I got error of can't insert null values so it couldn't read my selected value of the second…
Shery
  • 1
  • 3
0
votes
2 answers

How I can send null values in Geography SQL Server field if allow NULL, with SqlParameter and SQL Server Types SqlGeography in C#?

According to the following solution (https://stackoverflow.com/a/42976399/2825284): cmd.Parameters.Add(new SqlParameter("@position", position) { UdtTypeName = "Geography" }); My code: SqlGeography geographyfield = null; sqlParameter.ParameterName =…
Ejrr1085
  • 975
  • 2
  • 16
  • 29
0
votes
2 answers

Oracle SQL if statement based on parameter passed in via .sh script

I have a shell script which calls some SQL like so sqlplus system/$password@$instance @./oracle/mysqlfile.sql $var1 $var2 $var3 Then in mysqlfile.sql, I define properties like this: DEFINE var1=&1 DEFINE var2=&3 DEFINE var3=&3 Later in the file, I…
RoRo88
  • 306
  • 1
  • 4
  • 14
0
votes
1 answer

SQL Server stored procedure get many parameters

I'm new to SQL Server and I wonder: I have built some tables that display the documents that produced in my program. I need to write a stored procedure that inserts a document to the tables with transaction. I think to create a main procedure with…
T R
  • 1
  • 1
0
votes
0 answers

Powershell SQL trouble with non-char parameters

I have a PowerShell function that executes stored procedures in a SQL Server 2016 database. It works fine with any parameters of any char variant type, but it fails when encountering parameters of types such as int, numeric, or datetime. I get…
0
votes
2 answers

Is there is any way to change the webmethod parameter programatically?

Need to manipulate the asp.net web-service web method inputs before it getting executed. For example: I have one web method called web1(string inp1). Now, I am calling this web method with the input inp1 value as "Jagan drop table", but I need to…
Jagan T
  • 30
  • 1
  • 5