Click here to Skip to main content
15,884,054 members
Everything / Parameter

Parameter

Parameter

Great Reads

by Sergey Alexandrovich Kryukov
Rather insane yet simple approach to the named function parameters
by Uladzislau Baryshchyk
An overview of Dynamic Language Runtime DLR in C#
by Mel Padden
Default keyword in SQL Server
by ToughDev
How to identify used and unused resources in VS Project Resources.resx file

Latest Articles

by Coral Kashri
Fold-expressions in extreme cases
by ToughDev
How to identify used and unused resources in VS Project Resources.resx file
by Illya Reznykov
The post describes PowerShell script which creates WAF resources for the scenario when Application Load Balancer is used to serve content for a public website, but to block requests from attackers and to protect from OWASP Top 10 security risks.
by Uladzislau Baryshchyk
An overview of multithreading in C#

All Articles

Sort by Score

Parameter 

11 Mar 2017 by Sergey Alexandrovich Kryukov
Rather insane yet simple approach to the named function parameters
30 Jan 2022 by Uladzislau Baryshchyk
An overview of Dynamic Language Runtime DLR in C#
13 Mar 2015 by manchanx
This:typeof(myEnum) doesn't work because myEnum is your enum variable, not your enum type.Instead you have to write the name of your enum-definition there - the equivalent to what is HemEnum in the source you linked:public enum HemEnum{ [Description("none")] HemNone = -1, ...
17 Feb 2018 by OriginalGriff
As Phil has said, they are very similar. But ... if you aren't using the passed in value - as your example doesn't - then using ref is redundant and just adds extra overhead to each call. Using out parameters instead is more reflective of what you are actually doing. But ... I wouldn't use...
12 Jun 2011 by Mel Padden
Default keyword in SQL Server
20 May 2012 by sachin10d
Try thisMethod1:SqlCommand command = new SqlCommand("insert into TableName values (@Col1,@Col2)",connection);command.Parameters.AddWithValue("@Col2",DBNull.Value);Method2:SqlCommand command = new SqlCommand("insert into TableName values ...
9 May 2013 by ZurdoDev
You can use optional parameters in SQL. Just give it a default value. For example:ALTER PROCEDURE [dbo].[TESTSP] ( @param1 NVARCHAR (50), @param2 NVARCHAR (50) = NULL)ASBEGINIn this case, if I don't pass in @param2 then a null will be used.
17 Sep 2013 by Zoltán Zörgő
It is a matter of syntax. The "this" keyword is only marking that you make an extension method for the type of that parameter. But I like this syntax because it is really in line with the keyword's other usage.
21 Dec 2013 by OriginalGriff
No, you can't.The whole idea of Generics is that they are type unspecific - they are general purpose rather than linked to a specific class: so you can declare a List class that work as a collection of a generic class, and it will work the same with an integer and an SqlCommand.Declaring...
17 Feb 2018 by phil.o
ref and out are quite similar in that they allow to pass parameters by reference rather than by value. The only difference is that out does not need the parameter to be initialized before being passed, whereas ref needs an already initialized parameter. Beyond that, none is better than the...
28 May 2012 by DaveAuld
You could probably implement something along the lines of this;private void doSomething(String db1, String db2){ if (!(String.IsNullOrEmpty(db1))) { //Do this } else { if (!(String.IsNullOrEmpty(db2))) { //Do this ...
9 Apr 2013 by Prasad Khandekar
Hello,Hello,Generally your URL will be fix, what's going to change is the data you will be sending, which can either be sent as query string parameters or as POST request parameters. Since you are using POST request, your code should look something like//uses AJAX call to retrieve data...
17 Sep 2013 by phil.o
With the 'extension' method:public static class ScottGuExtensions{ public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"); return regex.IsMatch(s); }}you can use the method like...
15 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
The error message is quite clear.That means the StoredProcedure "DMLgrid_SP" is expecting parameter @id, but you are not sending that from code.So, do something like below to send the parameter.com.Parameters.AddWithValue("@id", someID);Also no need call ToString()...
8 Jan 2015 by OriginalGriff
Um...you did notice the sender parameter?Cast the sender as a Button, and you should be able to access the ID property for the specific button that was clicked.
18 Jan 2016 by Dave Kreskowiak
Not the way you're sample is thinking, no.You'd be better off just creating a second method with the appropriate operators in place.Other methods are possible but they introduce performance hits on top of the bad code you're already writing.Get/SetPixel are VERY slow to execute once...
13 Apr 2016 by CHill60
You can have as many parameters to Main as you like, that is why it is defined as a string[] rather than string.Although all of the arguments are passed into Main as strings, they can be converted to other types. See the reference Command-Line Arguments (C# Programming Guide)[^]
17 Feb 2018 by George Swan
I would say that neither of your options are the best. I would use a Tuple. Something like this: static Tuple Remainder(int dividend, int divisor) { int quotient = dividend / divisor; int remainder = dividend % divisor; return...
22 May 2019 by lmoelleb
yyyy-MM-dd HH:mm:ss is a format "for human consumption". It is not a good format for a database, nor a good format for a program. And it is certainly not a good format for a program to communicate with a database. It isn't even a good format for Excel, so most likely this is not what is stored...
8 May 2023 by ToughDev
How to identify used and unused resources in VS Project Resources.resx file
26 Jul 2010 by Andrew Rissing
The new instance of the datatable set into "tbldt" is being reset by the line:tbldt = (DataTable)xmlDatadocTimeTable.DataSet.Tables["TIMETABLES"];I would check to make sure your file "TimeTable_Full.xml" indeed has the TIMETABLES table. Because it seems, it does not.
20 Apr 2011 by Maciej Los
1) Only for the first time (i=0) you can add parameter! For the next loop you must change it!or...2) Build query in run-time in this way:sSQL = "INSERT INTO Tracks (TrackTitle, TrackSeqNum) " & vbCrLf & _"VALUES( '" & ListBox3.Items(i) & "', '" & ListBox1.Items(i)"')"Then you need to...
29 Feb 2012 by bcasillas
hi all!i just want to know if it's possible to pass a datatable as sqlparameter, becasuse I do not want to use a for-each to insert row by row in my databasebest regards!!improving my questioni had not a particular problem, i just want to know if it's possible to do something...
4 Jun 2012 by Manas Bhardwaj
According to Wikipedia[^]:1.) a represents the start/stop time of the device (intercept)2.) b stands for the inherent speed of the device (slope). These constants can be determined experimentally by fitting a straight line to measured data.
4 Jun 2012 by Richard MacCutchan
This is hardly a programming question; try reading this[^].
28 Sep 2012 by AspDotNetDev
With LINQ to Entities, it'd look like this (the context variable would be an instance of your entity model):var cars = ( from car in context.vehicles where car.make == makeComboBox.SelectedItem && car.model == modelComboBox.SelectedItem && car.model_year ==...
11 Mar 2013 by Zoltán Zörgő
Yes and no. And it depends on what you want exactly.NO: @getdate won't be a parameter, it will be a variableNO: it is not wise to declare a variable with the same name as a function in the same contextYES: you can declare and use variablesYES: you can store the output of a function in...
18 Apr 2013 by skydger
It depends on architecture of your application.Any COM method accepts only "known" parameters in its methods which are primitive datatypes, VARIANT-based or user defined interfaces. So if you want to invoke some method in its implementation it must be defined in some other interface. And your...
12 May 2013 by neteroxv
My mistake. I should have used."Select count(*) from [users] where [userid]=@uid and [password]=@pword"since I used Convert.ToInt32(cmd.ExecuteScalar())>= 1 which requires numeric result.1, 2 and 3 worked after I fixed my error in my select query.
17 Jul 2013 by Maciej Los
First of all, i would suggest you to NOT use insert/update/delete statements in code. Have you ever heard about SQL injection[^]? Better way is to use stored procedures[^].Second, you need to declare variable (for example) oCell, type: DataGridViewCheckBoxCell. Then you need to cast...
19 Aug 2013 by pradiprenushe
Yes you can do this using result of existing sp. Hope this will be helpfulDECLARE @cache TABLE (CountCol int NOT NULL)INSERT @cache EXECUTE usp_Yoursp @Id=123SELECT CountCol FROM @cache FOR XML AUTO
31 Oct 2013 by snamyna
Hye..I have 2 pages where I want to pass linkbutton value from iframe to its parent page.Parent Page vb code:Protected Sub...
20 Mar 2014 by Divakar Raj M
I want to call a method on two separate occasions. The two occasions pass two different types parameters, they differ by datatype. How do i achieve this without overloading.This is my codeusing System;using System.Collections.Generic;using System.Linq;using...
20 Mar 2014 by Kornfeld Eliyahu Peter
Read here about variable data type in C# (it's there since Visual Studio 2008/C# 3.0)...http://msdn.microsoft.com/en-us/library/bb383973(v=vs.120).aspx[^]
20 Mar 2014 by Matt T Heffron
Here's a start: public static void Hit(IList a) { Console.WriteLine(a[0]); }Both of the types of Lists you're using implement the IList interface.Without seeing what else you are doing I can't be sure, but using generics[^] looks like it may be a...
20 Mar 2014 by BillWoodruff
The easy way:private void TestHit(){ var intlist = new List {2, 3, 7}; var stringlist = new List {"A", "B", "C"}; Hit(intlist); Hit(stringlist);}private void Hit(List theList){ if (theList == null) throw new...
9 Dec 2014 by ZurdoDev
The url should repeat the parameters instead of delimiting it.So, your url should be http://inggfdsfyz/ReportServer/Pages/ReportViewer.aspx?%2fMonitorReport%2fFinalReport&CountryID=2628&Stateid=2&CityId=346&CityId=7
11 Jan 2016 by Alejandro Escribano Pindao
You can use reflection. Imports System.ReflectionPublic Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Me.setHandler("Click", CType(AddressOf test, EventHandler), Me.Button1) Me.setHandler("Click", CType(AddressOf test,...
15 Nov 2016 by abboudi_ammar
Good evening, I try to display an image in a reportViewer from a send path as a parameter. But the result I get is an image in X formWhat I have tried:public...
24 Mar 2017 by F-ES Sitecore
str='1,2,3,4,5';window.locat...
17 Jun 2017 by KarstenK
Using this technique in C++ is named callbacks. Here you find a tutorial about callbacks. As an experienced programmer like interfaces more, because type checking from the compiler, debugging adavantages and cleaner concepts like modularity and maintenance. Here you find some tutorial about...
17 Jul 2017 by Jochen Arndt
When using the struct keyword in your function declaration you have a so called "forward declaration": // Forward declaration // Definition must be present later in this scope struct Student; // Can now use the forward declaration within other declarations void passStructAsParam(Student s); ...
26 Jan 2018 by OriginalGriff
You can't add parameters to main - it needs to have a specific signature - which means it needs to have very specific input and output parameters, and you adding or removing them changes the method signature and means that the system doesn't "see it" when it looks for the method to call at...
26 Feb 2018 by Richard MacCutchan
PHP mysqli_select_db() Function[^]
23 Jan 2023 by leone
Ok I did it on my own: Material m=new Material(URL); process.OutputDataReceived +=(Object _sender, DataReceivedEventArgs _args)=>DoSomething(m, _sender, _args); public void DoSomething(Material mt,object sender, DataReceivedEventArgs e) { ...
25 Jun 2021 by Patrice T
What happens to $query when $_SESSION['user_role'] is neither '1' or '0' ? if($_SESSION['user_role']=='1'){ $query="SELECT post.post_id, post.title, post.description, post.post_date, category.category_name,user.username FROM post ...
28 Nov 2021 by #realJSOP
You could do it this way: public void DistributeChocolatesByAge(int choc) { ChocolatesDistributed(choc, People.OrderBy(x => x.Age).ToList()); } However, I would probably move the sort operation into the ChocolatesDistributed method so...
28 Nov 2021 by Marc Clifton
Pass in the sort as a lambda: public void DistributeChocolates(int choc, Func sorter) { People = People.OrderBy(sorter).ToList(); ChocolatesDistributed(choc); } Call with: DistributeChocolates(5, x => x.Age);
29 Nov 2021 by Marc Clifton
Here's the full example. Not really sure what you're trying to do with numChocolates, but the rest of it illustrates passing in the order by expression. Note how it handles any type, such as int, string, double. It was interesting to figure...
17 Feb 2022 by Pete O'Hanlon
What is an array and how to use it to manage multiple items
5 Aug 2010 by Alejandro Barrada
How to pass custom args to the OnSuccess callback function of javascript ajax
8 Nov 2010 by TraceD
Hi all,I need to pass an event as a parameter to a function and I'm wondering if there is any way of doing this. The reason why I need to do this is because I have a sequence of two lines of code that is littered all over my program, where I dynamically remove the handler to an event,...
8 Nov 2010 by E.F. Nijboer
There is no use for this code:Private Sub setHandler(evt As Event, hndler As eventhandler)RemoveHandler evt, hndlerAddHandler evt, hndlerEnd SubYou remove and then add the same handler. It's useless to do this. It's somewhat the same as this code:temp = aa = 100a =...
25 Dec 2010 by Chiranthaka Sampath
I have a program created using VB 2005 and MS Access 2003. In the program i have created a data grid which is connected using JET.4.0 OLEDB data provider. The data is been entered from text boxes to the data grid. I want to create a report using crystal report parameter passing which comes with...
22 Dec 2010 by fjdiewornncalwe
Try reading some of these articles.
28 Dec 2010 by Chiranthaka Sampath
I have a program created using VB 2005 and MS Access 2003. In the program i have created a data grid which is connected using JET.4.0 OLEDB data provider. The data is been entered from text boxes to the data grid. I want to create a report using crystal report parameter passing which comes with...
1 Jan 2011 by thatraja
Chiranthaka Sampath wrote:Am I on my own in here?Because most of people enjoying new year with their family & friends. Happy new year wishes for you.Ok here you go.How to pass discrete parameters to Crystal Reports[^]VB.NET Crystal Reports String parameter[^]Crystal Reports...
28 Jan 2011 by Chiranthaka Sampath
When creating crystal reports in VB 2005, passing parameters should I get one by one parameter for each field in the table which will be used for the creation of the crystal report? If so then how can I do that?
29 Jan 2011 by Sandeep Mewara
Have a look at these:Tip: How to pass Crystal Report Parameters Programmatically[^]How to pass discrete parameters to Crystal Reports[^]Passing Parameters to Crystal Reports at Runtime[^]If needed, go here[^] for more.
8 Feb 2011 by raghumaruka
Hello everyone!I am using a Datalist to display records. Each record has an Image and a hyperlink to more information. Now I need that hyperlink navigateUrl have two parameters. One for userId and second one for userName. To find out which record's hyperlink was clicked the key for the record...
8 Feb 2011 by Albin Abel
It is not clear why can't the record id also append in the query string as each record display a hyperlink.It may not be safe to pass the user id in the url string. Refer this article for further information how to securely pass the query string parameters.Preventive Method for URL...
20 Apr 2011 by Thraxman
Hello, Was hoping I could get some help with this code. I'm trying to fill the table with the data found in two Listboxs. But I'm an getting an error: SQLException was unhandled. The variable name '@TrackTitle' has already been declared. Variable names must be unique within a query batch or...
20 Apr 2011 by Costica U
You can use parameterized query like this. Note that parameter are added before for loop and have the value updated in the loop.objConnection.Open() .CommandText = "INSERT INTO Tracks " & _ "(TrackTitle, TrackSeqNum) " & _ ...
10 Jun 2011 by thatraja
Here you go .... solved linkThe report definition for report 'xxx' has not been specified[^]
28 Jul 2011 by adnama
i have this codepublic partial class ScenarioEditorView : UserControl, IScreenSelectorSubItem, IActionable, INotifyPropertyChanged { ScenarioEditorViewModel viewModel = new ScenarioEditorViewModel(p1);the initialization is out of the method because it is used in...
28 Jul 2011 by #realJSOP
You can:0) Implement a public method to initialize the variable (passing the path as a parameter to the method).1) Make a public property that can be set externally of the class that contains it2) If the variable only has to be set one time, you could pass the path as a parameter to...
14 Oct 2011 by 07navneet
hi,i am having trouble with this problem from last week.The problem gets more trickier bcoz when I try to insert record it shows this error"Procedure or Function 'Nav_Bulletins_Insert' expects parameter '@Bulletin', which was not supplied." but in DB the value is stored!PLease solve this...
14 Oct 2011 by OriginalGriff
Somewhere, you code must supply a parameter to the stored procedure called (as if you couldn't guess) "@Bulletin"Since you don't show us where any of the parameters are specified, we can't really comment on the specifics of the problem, so we have to go with general advice.Put a break...
23 Oct 2011 by Herman<T>.Instance
Hello everyone,I have a question about a query in a stored procedure.When the used parmeter @parm is null in my where clause the syntax should beand columnname in (select idfield from otherTable)if the @parm is filled with a value the syntax should be:and columnname = @parmHow to...
24 Oct 2011 by Herman<T>.Instance
Admitting: this was a headache for 3 people but it works...AND (@parm is null OR @parm = CASE WHEN Isnull(@parm,0) = 0 THEN CASE when columnName in (select id from table) then columnName ELSE @parm END ELSE ColumnName END)
23 Nov 2011 by contact97438
Hello everyone,I want to save a Custom DateTimePicker.Value in my Application Settings. The custom format is : dd/MM/yyyy hh:mm:ss, instead of dd/MM/yyyy The field i've created in the application settings parameters is LASTSAVE (DATE / APPLICATION)When I try to link in the...
23 Nov 2011 by Richard MacCutchan
Don't save date and/or time values as strings; use System.DateTime[^] variables. In that way it will be valid for every system in the world; only when you need to display the value do you need to convert it to a readable string.
24 Nov 2011 by contact97438
Is it possible to save a CHECKLISTBOX (not only a Checkbox) in the application settings ?I want to retreive my checkboxes checked in my CheckListBox when i load my form ?
24 Nov 2011 by Not Active
You don't save a control, you persist the controls state and values. Yes, it is possible to have this stored in you app.config
8 Feb 2012 by Christian Graus
If by Access, you mean the Access presentation layer, not just the DB, then the answer is probably no. If you mean the actual DB, then the answer is still no, but it's easier to poll the DB for changes.
8 Feb 2012 by Sharonc7
I want the MS Access in vba to tell the C# program what database to use by passing the param "Production" for the production database or "Development" for the Development database.Sharon
8 Feb 2012 by Sharonc7
Hi,can someone tell me how to pass parameters from MS Access to C#? Can this be done?Thanks,Sharon
29 Feb 2012 by Herman<T>.Instance
The SqlParamater.SqlDBType cannot be set to a DataTable object.See here[^]. You have to do rowbased updates.
27 Mar 2012 by Peace ON
Special Character # in URL Query String creates problem
11 May 2012 by Yasin KARATAŞ
Hi! I must use a PHP WebService by C# but I can't send multidimensional array parameter to PHP WebService. How can I send a multidimensional array to PHP WebService.string[,] _multidimensionelArray = new string[5, 5];richTextBox1.Text = _imp.importSelling(_token, _selling,...
20 May 2012 by Velkumar Kannan
Hi, I am using SqlCommand to insert or update values in a row of a table. I have added the parameters in the sqlcommand object. I want to update some of the column values to null. How can I update a cell with the value as NULL.Thanks,Velkumar
20 May 2012 by Zoltán Zörgő
Here are some methods: http://stackoverflow.com/questions/4555935/how-to-assign-null-to-a-sqlparameter[^]
28 May 2012 by mamali80
Hello everyone,I am trying to understand how optional and named parameters are work, so far I have managed to implement these options with my function, but now i have realised that this is not what I want.Basically I want a function that provides selective values, for instance let say I...
28 May 2012 by Andreas Gieriet
How about employing null and the ??-operator? E.g.// take one or the other argument.// If a is null, take b; if both are null, take "...".public void Func(string a = null, string b = null){ string c = a ?? b ?? "..."; // do something with c...}CheersAndi
5 Jun 2012 by rnbergren
Gives a run down of how to sort parameters for sharepoint lists selections
23 Aug 2012 by Karl Sanford
You could use the skeletal smoothing, and that should help a bit. The best way I've found is with a moving average of your desired target (in your case, the mouse location). So instead of simply moving the cursor every time you have a movement in your fingertip point, use a queue to store the...
3 Sep 2012 by AmitGajjar
Hi,First your method of generating Invoice number is incorrect. You should not use logic for generating Invoice number in C#. Instead i suggest you to use AutoIncrement Number in database to generate your invoice Number. Or if you have complex InvoiceNumber then you can create one SQL...
28 Sep 2012 by joshrduncan2012
Hi everyone,Is it possible to transform a query with parameters into LinQ to SQL (keeping the parameters in tact)?This is what I have so far in plain SQL.SqlCeCommand trans_comm = new SqlCeCommand("SELECT DISTINCT transmission_type FROM vehicles WHERE make = @make AND model_name =...
3 Oct 2012 by ggoutam7
Hello,I am trying to fix this bug. Please help.I am getting below error and no data inserted :"Must declare the scalar variable "@bytImage"." Public Sub InsertFile() Dim sMainFolder As String = "D:\Project" Dim conAccess As Data.OleDb.OleDbConnection ...
3 Oct 2012 by Santhosh Kumar Jayaraman
When using OleDb the parameters in the SQL are to be set to ? and not @bytImage.try thiscommSQL.CommandText = "INSERT INTO [PICS] ([IMAGE]) VALUES (?)"
16 Oct 2012 by armarzook
I would like to have help regarding passing the parameter directly to the crystal reports in which it returns the value of current cell with all of its key references.The situation as of now is if i run the program and call the crystal report, A Dialog box appears asking "Enter Parameter...
8 Feb 2013 by Member 9742322
also at the end there was one bracket to many
8 Feb 2013 by Member 9742322
also at the end there was one bracket to manyand :DATETO)
11 Mar 2013 by gvprabu
Hi Friend,Read the following links...you will get some Idea about Data types and variables.Data Types (Transact-SQL)[^]SQL SERVER 2008 – 2012 – Declare and Assign Variable in Single Statement[^]Table-Value Parameters in SQL Server 2008 - VB.NET[^]Global Variables in SQL...
7 Apr 2013 by Member 9592868
I am using the HighStocks javascript library to create a chart on my website using finance data taken from Yahoo.I have an external javascript file with these functions: //uses AJAX call to retrieve data and then creates the chart with the data function createChart(ticker) { ...
9 Apr 2013 by Sharan Khanal
I am trying to populate gridview from storeprocedure using LINQ. I have created storeprocedure and dragged it to .dbml file.My Store proc is as follow:create proc sp_getReportDateWise@fromDate date,@toDate dateas select * from tblreport where Date BETWEEN @fromDate AND...
9 Apr 2013 by Karthik Harve
Hi,try by modifying the LINQ query like below.var report = (from r in db.sp_getReportDateWise(Convert.ToDateTime(txtFromDate.Text), Convert.ToDateTime(txtToDate.Text)) select r).CopyToDataTable();also, make sure the procedure is giving result set and the gridview is having bound fields...
9 May 2013 by Member 9960197
Hi,A mere help needed, I am creating an mvc app wherein i take user input say CustId CustName and CustPhone.I have written a procedure for it which works fine when i enter all 3 values as input.Now, sometimes need be,i may not enter CustName or CustPhone for an id.if i do so i get an...
12 May 2013 by neteroxv
Hi I'm new to vb.net.I'm having error input string is not in the correct format. I already used different codes for adding a parameter in sql select query.I would like to ask what is the best way of adding a parameter in a VB.net select query?Thanks in advance. Dim strsql As String...