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 Parameters and No command text is defined for the command object error

I would like to create my first SQL Parameters command with c#, and i have an error : "No command text is defined for the commande object" Here is my code : string maRequete = "UPDATE " + strNomTable + " set everelance = @everelance," +…
Walter Fabio Simoni
  • 5,671
  • 15
  • 55
  • 80
0
votes
0 answers

ASP.net How to use a sql parameter for a datasource

I'm trying to load some specific information on a page depending on what logged in user loads the page. I did my best googling my problem but I couldn't find the solution.
Pablo
  • 111
  • 4
0
votes
1 answer

Setting SqlDataSource SelectParameters from form text box

I am trying to use a text box input as a SqlParameter but it only goes into DataSelecting when the page first loads. Not after the from is submitted. Here is the code on the aspx page. protected void DataSelecting(object sender,…
Droter
  • 21
  • 4
0
votes
6 answers

The SqlParameter is already contained by another SqlParameterCollection

I'm using EF DbContext SqlQuery to get a list of paged objects using PagedList (https://github.com/TroyGoode/PagedList) and I'm getting the following error: "The SqlParameter is already contained by another SqlParameterCollection" Here's my…
0
votes
3 answers

How to create C# Method with sqlconnection executing stored procedure with Array of Parameters

With the below code, I am executing the stored procedure named, "sp_InsertTradingAcctTransFront" with 4 parameters. Now, instead of typing each of the parameter, i wanted to do it the parameter and field as Array. Like: cmd.Parameters.Add(new…
donubas
  • 51
  • 4
0
votes
1 answer

Run reports/send emails from a list of parameters?

I've run into a problem that, although I feel in my gut there is a 'simple' resolution, I'm not getting anywhere with it! The reports I'm running are using a dataset that includes a username that I need to use to 1) Use as a parameter for running…
0
votes
2 answers

sql query to get a scheduled report to run for that curent month only

I have an SSRS 2005 report that has a dataset for to an Oracle database. The report that i have essentially just pulls all data back from an audit log. This report works perfectly fine and i have scheduled thi to run and send an email using the…
Betty B
  • 185
  • 1
  • 4
  • 20
0
votes
2 answers

C# Sqlparameter add

i have a class for my sql duety, and have problem for my how could i do something like this SqlParameter storedparam = new SqlParameter(); SqlParameter param1 = new SqlParameter("@userid", SqlDbType.BigInt); param1.Value = "87"; SqlParameter param2…
Mahyar
  • 796
  • 4
  • 16
  • 34
0
votes
4 answers

Avoid SQL Injections on query with tablename

Possible Duplicate: Sanitize table/column name in Dynamic SQL in .NET? (Prevent SQL injection attacks) I have a query like so: "SELECT * FROM MyTable_" + myID + " WHERE variable = @variable"; The SQL Parameterization works with variables, but…
cdub
  • 24,555
  • 57
  • 174
  • 303
0
votes
2 answers

C# and SQL parameters to prevent injections

I am wondering how (in my code below), that I make sure that dataID is a text (or varchar or int) in the parameter passing below? public T ExecuteQuery(Func getResult, string query, params IDataParameter[] parameters) { …
cdub
  • 24,555
  • 57
  • 174
  • 303
0
votes
2 answers

How to Use a parameter within SQL in Vb 2010 (web developer)

I am trying to work out SQL code in VB but I am having problems I have a simple database with the table admin with the columns UserName and Password. I want to be able to read data from a text box and then input it into a SQL string… the SQL string…
Will Peckham
  • 574
  • 1
  • 7
  • 18
0
votes
1 answer

Microsoft Access Parameter Query Fails Occasionally

I have a query that, basically, says this: SELECT DISTINCT [DB_ID] FROM [TableX] WHERE ([ForeignKey]=@ForeignKey); Once I have this, I return the first DB_ID (there should be only one). The routine I've written for calling this is in C# so that I…
user153923
0
votes
2 answers

SqlCommand stored procedure without a named parameter

I've written a query parser that should create a SqlCommand and execute a stored procedure. The query for the stored procedure can come in many forms, including this one: exec dbo.sp_StoredProcedureName 1599800 In this case, I create the…
duckus
  • 213
  • 3
  • 15
0
votes
1 answer

Dynamic parameters for sql query with "IN" operator

I have an ASP.NET website (c#) and in the code-behind I want to use the IN operator in SQL http://www.w3schools.com/sql/sql_in.asp to get data from my database. The syntax is: SELECT column_name(s) FROM table_name WHERE column_name IN…
Zelter Ady
  • 6,266
  • 12
  • 48
  • 75
0
votes
2 answers

SqlParameter and ExecuteNonQuery causing unrepeatable time outs

I recently inherited some code that is having occasional time-out issues. I am mostly familiar with ORM's, so I am having trouble determining if anything is wrong in this code. When it does not time out, it works in a couple of seconds. Time-outs…
PFranchise
  • 6,642
  • 11
  • 56
  • 73