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
1
vote
4 answers

Send a empty DateTime value into SQL stored procedure. But not null

I have an SQL stored procedure which accepts a DateTime parameter which has a default value of NULL @pmNext_Check_Date DATETIME=NULL I want to use this parameter in 3 scenarios: If it's NULL then don't update any records If it's got a date value…
Sun
  • 4,458
  • 14
  • 66
  • 108
1
vote
2 answers

Unrecognized escape sequence when using a path as a SQL parameter

I am trying to store a string or nvarchar(500) in SQL. When I pass a full file path as a string parameter, there is an error unrecognized escape sequence. Since path is not an usual param that this stored procedure expects, how can I open this…
mko
  • 6,638
  • 12
  • 67
  • 118
1
vote
1 answer

Entity Framework. ExecuteStoreQuery Error converting data type varchar to real

I'm trying to execute a story query with Entity Framework. I've been trying this for ages. The data type I'm passing in starts off as double. I then found that real in SQL was a single, so I convert to single. (radius is an int) But I get this…
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
1
vote
2 answers

WCF from Data Access Layer

I have a problem i am struggling to create a WCF Service Application form this Data Access Layer : public class DataAccess { private SqlConnection connection = new SqlConnection("Data Source=LAPI;Initial Catalog=PrimierData;Integrated…
J03Fr0st
  • 11
  • 4
1
vote
2 answers

Procedure expects a parameter which was not supplied

Towards the end of my code I am calling a stored procedure which updates a table based on the parameters passed by my page. I get the following error: Procedure or function 'Res_invpush_UpdateInv' expects parameter '@InventoryPushSubscriptionId',…
user1270384
  • 711
  • 7
  • 24
  • 53
0
votes
4 answers

Create SQL parameters programmatically

Another annoying one for me but probably something simple. I have a number of possible where clauses for a query based on user input, my question is how can I add these programmatically? For instance: wherequery = @"WHERE fieldname = @p_FieldName…
Neo
  • 2,305
  • 4
  • 36
  • 70
0
votes
5 answers

how to get the full sql query including parameters

I have recently leaped into parametrized queries in SQL. I am now getting a complaint about a date when executing the query The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar. When I get the…
Neo
  • 2,305
  • 4
  • 36
  • 70
0
votes
2 answers

Failed to convert parameter value from a DateTime to a Byte[]

I'm getting error converting parameters from DateTime to Byte[]. The idea is to show data between 2 specified dates that are entered via controls and displayed on GridView, and using a stored procedure to access data. I don't understand the error,…
malvina
  • 33
  • 1
  • 7
0
votes
1 answer

JSON Serialization and .NET SQL Parameters

I have recently joined a team where they are using JSON serialization to pass parameter arrays to SQL Server stored procedures where they are then deserialized and the required values extracted i.e. Each stored procedure has a '@Parameters'…
Trev
  • 48
  • 1
  • 6
0
votes
1 answer

SqlParameter returns null in Entity Framework SqlQuery

I am materializing entities through a stored procedure in Entity Framework Code-First. The Stored Procedure takes an int parameter and outputs both a selection of records and several output parameters. For whatever reason, I am getting Null back…
CodeWarrior
  • 7,388
  • 7
  • 51
  • 78
0
votes
1 answer

WebMatrix / WebPages / SQL Compact - Named SQL Parameters

How do you add named SQL Parameters in WebPages Framework? var db = Database.Open("database"); var stories = db.Query("select * from story where category = @1", 545433); I only see parameters such as the above code, they are numbers, I want them…
kazinix
  • 28,987
  • 33
  • 107
  • 157
0
votes
0 answers

Linq-to-SQL stored procedure and SqlParameters

I have Linq-to-SQL and a stored procedure (with generated .dbml file and usp calling like a method) and .NET. So: public IEnumerable usp_Orders_Process_Select() { return…
FSou1
  • 1,861
  • 4
  • 18
  • 25
0
votes
1 answer

SqlCommand Parameters Clarification

I was told that if using SqlCommand in C# and if you were to add parameters to that command, that it will add security since it will protect against Sql Injection. I was wondering if this is in fact true. If so, how can it stop Sql Injection…
Eric R.
  • 1,105
  • 3
  • 21
  • 48
0
votes
2 answers

Any way to pass a SqlParameter from one class to another?

I have a class, LogRequest, which contains parameters (members) for an object. This object is turned to an sql query using another class, DataAccess. And lastly, I have the class Search which run the sql query. In Search : 'Create the request Dim…
Kraz
  • 6,910
  • 6
  • 42
  • 70
0
votes
1 answer

Sql paramters appear to not add in the single quote for strings(commit transaction issue)

I wasn't sure exactly how to phrase the question Title. I have this block of code that sets up my sql parameters for a stored proc that does an insert. Dim sproc As StoredProcedure = New StoredProcedure("UsersInsert2", DataAccessConfiguration) …
TeddyRuxpin
  • 99
  • 1
  • 12