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

how to store only time in sql server when object data type is DateTime in c#

my objects WDst,WDet,SATst,SATet are DATETIME class objects which contains value of time from the text boxes. all the start time and end time parameters in my SP are of dATA type Time(7) how can i use DateTime Object i use following code to insert…
Sana.91
  • 1,999
  • 4
  • 33
  • 52
0
votes
2 answers

Passing Integer values to SqlParameter in .net

i want to pass integer value to the SqlParameter which is executing an SqlDataReader, but when i pass integer value it says, the Parameter is not supplied, below is my code: Common SqlDataReader Function public static SqlDataReader…
Abbas
  • 4,948
  • 31
  • 95
  • 161
0
votes
1 answer

Procedure or function 'AddUpdateContactDetails' expects parameter '@Id', which was not supplied

I have my method using (var helper = new DbHelper()) { _commandText = "AddUpdateContactDetails"; var parameter = new[] { new SqlParameter("@Id",…
user240141
0
votes
1 answer

How to check if sqlParameter is empty?

I have a class, which has many "New()" functions to initiate it with various parameters. I would like to create a New() function that will init the class with no arguments. The problem is there is a "fillData" function which fills the data for the…
russds
  • 845
  • 5
  • 25
  • 48
0
votes
3 answers

SqlCommand with parameters as a string

I have an application I need to create which, given some user input in the form of CSV, needs to parse and generate this CSV into multiple formats. One of these formats is a series of SQL INSERT statements (as a string) for each line of CSV. (At…
daniel
  • 1,148
  • 1
  • 13
  • 20
-1
votes
2 answers

SQL OutParameter Not Working

private static SqlParameter AddNewParameterToCommand(SqlCommand command, string name, object value, bool isOutputParameter) { SqlParameter parm = new SqlParameter(); parm.ParameterName = name; parm.Value = value; …
shenn
  • 859
  • 4
  • 17
  • 47
-1
votes
1 answer

When calling a stored procedure with ADO.NET, how do I tell what parameter types the database actually used?

I have a stored procedure call in C#. It uses ADO.NET to call the stored procedure that is on my SQL Server. Despite knowing that one of the parameters of the stored procedure on the server is VARCHAR(120), I used AddWithValue to add it to my…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
-1
votes
1 answer

Exception thrown when it shouldn't be

private async Task InsertCustomerRecord(CreateCustomerModel model) { Int64 phoneNumber = 0; var isParsed = Int64.TryParse(model.PhoneNumber, out phoneNumber); if (!isParsed) phoneNumber = 0; …
software is fun
  • 7,286
  • 18
  • 71
  • 129
-1
votes
1 answer

Method Overriding in SqlParameter

I am using parameterized query in C# with following piece of code: int i = 5; string query = "select col1 from table where col2 = @prm1 and col3 = @prm2"; SqlCommand cmd = new SqlCommand(query,connection); cmd.Parameters.Add(new…
Harshil Doshi
  • 3,497
  • 3
  • 14
  • 37
-1
votes
2 answers

Create SqlParameter with name and type only (no value assigned)

I am having issue to use SqlClient to call some sql query with parameter declared but not assigned. The query I want to run is similar to below DECLARE @ID int; SELECT @ID = OrderId FROM Orders ORDER BY OrderId DESC; SELECT @ID; However, when I…
katrinawyh
  • 23
  • 3
-1
votes
2 answers

access sql-parameter with dbnull

I want to update some rows in my accessdatabase. When typing the whole query in the commandtext-object, everything works just fine. But when i try to use the parameters the DBNull-value doesn't get recognized: Here is how i do this: using (var…
Olli
  • 658
  • 5
  • 26
-1
votes
1 answer

Use sql table like sql parameter in vb.net

I have query with sql parameters. My parameter must be my table from database and I don't now how I can realize this. I did it so: myCommand = myConnection.CreateCommand() myCommand.CommandType = CommandType.Text myCommand.CommandText = "SELECT Id,…
Emma W.
  • 215
  • 1
  • 6
  • 20
-1
votes
1 answer

Is it possible to use wildcards in SQL Server Stored Proc parameters?

I am working with a Stored Proc with takes several parameters. It turns out, though, that for one of the params, I need to loop through a list of items and call the SP multiple times. But as I pass the SP every possible value of that type, it would…
-1
votes
1 answer

Insert data to master detail tables by a stored procedure

I'm trying to add data to my master/detail table by using a stored procedure. I tried this: private void ekle() { MySqlCommand cmd = new MySqlCommand("invinputfrompo", bag); cmd.CommandType = CommandType.StoredProcedure; …
-1
votes
3 answers

SqlParameter doesn't work with a schema name

I am attempting to use SQLParamaters to construct my SQL command. It works fine when I use them in the “where” clause but fail when used as part of the schema name. Here is the sample SQL string with the code for the problematic parameter. I’ve not…
Retrocoder
  • 4,483
  • 11
  • 46
  • 72