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
2 answers

Save large binary data into sql DB with C#

I need a code to store (eventually large) files into DB using C#. The solution I'm using is sth like: (I'm using varbinary(MAX) column in the DB) 1) Create SqlCommand 2) Create SqlParameter 3) Set parameter.Value = File.ReadAllBytes(filePath) 4)…
0
votes
1 answer

Using Sql parameters on Ingres Database error

Exception: Local variable/parameter ':your-param-name' can only be used within a database procedure. In MSSQL, the param character is @. In INGRES Database, really is : ? I cannot find official documentation for that... SELECT * FROM MyIngresTable…
0
votes
1 answer

C#_ Incorrect data when use SqlParameter and Bulk SQL

This is my code : string sqllaydl = @"BULK INSERT dbo.Infosp1 FROM '@laydl' WITH (FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')"; SqlCommand cmd = new SqlCommand(sqllaydl, con); SqlParameter para = new SqlParameter(); para.ParameterName =…
0
votes
1 answer

Query Returns Nothing when using SqlParamter: Entity Framework

I wrote a query to display jobs that meet specific criteria in a production line. Basically, it shows jobs that are "works in progress" (WIP) for a specific section of a production line at my work place. I am using the following to execute my…
Caleb W.
  • 129
  • 2
  • 11
0
votes
1 answer

Using DbParameter instead of SqlParameter with _context.Database.SqlQuery for stored proc execution

I am using Entity Framework 6.1 and GenericRepository. To execute stored procedure I am using SqlQuery method. Currently I am using SqlParameters but being a GenericRepository I don't want to use some specific class. I tried multiple options but how…
0
votes
2 answers

SQL Insert with Select and Parameter

Hello I have a problem declare @target_date datetime set @target_date=GETDATE(); insert into table1 ([column1],[column2],[column3]) (select [column1],[column2] from table2 where id=@id), @target_date How can I solve this…
BK52
  • 754
  • 2
  • 11
  • 33
0
votes
1 answer

Using parameter in query results in BEGIN / COMMIT mismatch SQLException

The following code executing a bunch of SQL statements works well... // SQL Server 2008 R2 SqlConnection connection = null; var runBatch = false; try { connection = new SqlConnection(connectionString); connection.Open(); var command =…
marsze
  • 15,079
  • 5
  • 45
  • 61
0
votes
0 answers

C# Sql parameter expected, parameter is not in SP parameter list

Getting a "Procedure or function 'InsertAccount' expects parameter '@AccountId', which was not supplied.", however the stored procedure does have this parameter in its parameter list. The C# code: using (var connection = new…
0
votes
1 answer

INSERT Query with Parameters in VS2010

I do not understand why it's not inserting to my database whenever I include an apostrophe in my txtParticulars.Text and txtPayTo.Text. The error is this:Syntax error (missing operator) in query expression ''Joy's Boutique','Top's,'Issued')'. My…
Erica
  • 3
  • 1
  • 6
0
votes
1 answer

Trying to pass parameters from asp.net when using a DECLARE statement but getting an error saying "Must declare the scalar variable "@pID"

I have a table called ReportValues that stores all the information about a player in key and value pairs. The table has a foreign key from another table called Reports. I'm trying to get all the data in one row for each report where the keys will be…
Orensig
  • 27
  • 1
  • 7
0
votes
1 answer

Incorrect syntax near SqlParameter

I have this code Dim q = New SqlCommand("SELECT * FROM [ddddd] WHERE ([Day] >= %XX ) AND ([Day] <= %YY )") q.Parameters.Add(New SqlParameter("XX", rangeFrom.Value)) q.Parameters.Add(New SqlParameter("YY", rangeTo.Value)) q.Connection = dbc Dim rd…
Misaz
  • 3,694
  • 2
  • 26
  • 42
0
votes
3 answers

Adding Quoted Datetimes from Paramaters in Dynamic SQL String for sp_executesql

I am currently working on an SQL Server 2005, and trying to structure a dynamic query as follows: DECLARE @GETDATE AS NVARCHAR(12); DECLARE @GETDATE2 AS NVARCHAR(12); SET @GETDATE = ...; SET @GETDATE2 = ...; SET @SQL = 'CREATE TABLE [dbo].['…
3BK
  • 1,338
  • 1
  • 8
  • 11
0
votes
0 answers

Sql Parameters passing with @parameter = value type

I am using an accounting program. I want to implement one feature of this program to my C# application. Accounting Program uses MS SQL database. So I have looked up SQL trace logs via SQL Server Profiler. Accounting Program sends this command to…
erhanzeyrek
  • 36
  • 2
  • 8
0
votes
2 answers

Generic procedure execution method for DAL incl. parameters

I am trying to create a "generic" method in a data access layer that executes a passed stored procedure in Sql Server and also takes a list / array / collection of SqlParameters, to make the usage of a stored procedure call within other parts of the…
Magier
  • 437
  • 1
  • 6
  • 18
0
votes
1 answer

Stored procedure with char[n] input parameter not getting called from EF with string SqlParameter

My SQL Server stored procedure expects two char(2) parameters. I am passing it string as following but the stored procedure returns no data. this.parameters.Add(new SqlParameter("A", this._A));//this._A is string type this.parameters.Add(new…