Passing An Optional Parameter To A Webservice

Nov 1, 2010

Is there a way to pass an optional parameter to a webservice, instead of having to overload the method?If the webservice user is accessing the webservice directly, I want to do ActionA, if the user is accessing the webservice through my web interface, I want to do ActionA + ActionB.

View 1 Replies


ADVERTISEMENT

Passing Null To An Optional Parameter With Default Value?

Sep 22, 2010

I think this is a pretty basic question, but I just want to clarify. If I have a variable with a null value, and pass it as a parameter that is optional, will the parameter get the null value, or the default value?

dim str As String = "foo"
dim obj As Object
//call 1

[code].....

View 1 Replies

Add A Optional Parameter In Visual C# Function?

Mar 14, 2012

How can i create a optional parameter in C# as we create in VB.Net

Public Sub Demo(ByVal a As Integer,Optional ByVal b as integer=3)
End Sub
I want to declare this in C#

[code].....

View 2 Replies

Have An Optional Parameter Of The Type List?

Sep 25, 2009

Is it possible to have an optional parameter of the type list?Ex.

Private Function TestFunction(Optional ByRef MyList As List(Of Double))

The real problem is giving the list a default value. When dimming a new list, you can use the code below to give it a starting value:

Dim MyList As New List(Of Double)(New Double() {1, 2, 3, 4, 5})

But even after trying many variations of the above code, I cannot get it to work as an optional parameter.

View 16 Replies

Using Color As Optional Parameter In A Sub/function?

Nov 3, 2010

how can use color as an optional parameter in a sub/function?This doesn't work.

Code:
Public Sub WriteLog(ByVal sText As String, Optional ByVal lColor As Color = Color.Blue)
'Code
End Sub

View 5 Replies

Using Double.NaN In Optional Parameter On Interface?

May 27, 2010

I have come across something confusing or potentially a bug in Visual Studio 2010 when defining an interface in my VB application: When defining an interface method with a default parameter of type Double, using the Double.NaN constant as the default value causes the code editor/intellisense/precompiler some issues.The following code underlines "INaNTest" and "INaNTest.DoSomething" claiming that 'DoSomething' cannot implement 'DoSomething' because there is no matching sub on interface 'INaNTest':

[code]...

where now "NaN" has been divorced from the "Double." prefix and underlined ('NaN' is not declared. It may be inaccessible due to its protection level.) The code editor has inserted invalid code again.Is there a correct solution to using Double.NaN as the default value for a method as defined on an interface, in VB.net, or is there a fundamental reason why this is impossible?

View 2 Replies

Databind To Object Parameter That Has One Or More Optional Parameters?

Mar 22, 2011

I have an object, called 'PERSON' This person object has a title, firstName & Surname property as well as many other which are at the moment irrelevant. It also has a read only property called Fullname which concatenates the two or three parameters mentioned above depending on an optional parameter 'withTitles' passed over when you call PERSON.FULLNAME

PERSON.FULLNAME(true) <- Will add titles if there are any

PERSON.FULLNAME(false) <- Will give the name without the title

Public ReadOnly Property FullName(Optional ByVal withTitle As Boolean = False) As String

[Code]...

I get an error: PERSON does not contain a property of 'FullName'. If I change this to any other property that does not take a parameter it works as expected. Now I'm guessing that the binding procedure can't handle optional or mandatory parameters for object properties, is this right? Is there a better way to do it? I thought about looping through the collection to add them manually but that kinda defeats the object of DataBinding!

View 1 Replies

Declaring Optional Controls - Parameter Must Specify Default Value

Jul 28, 2010

I have a problem during defining a Sub routine in VB.Net. I am defining a sub routine which is as under
Private Sub ActivateControls(rdbutton as RadioButton, Optional txt as Textbox, Optional txt2 as Textbox)
End sub
When I call this sub routine It gives me the Error that Each Optional Parameter must specify a default value. So, Here I can't understand that what can be the default value of a textbox. What default value I can use here to remove this error.

View 6 Replies

Optional Method Parameter And String.Empty?

Apr 19, 2012

I have traditionally coded empty strings like this "", but for a couple of years now, I have been using String.Empty.I also normally never use optional parameters, but I'm refactoring a solution that's tied into my ERP, and I don't want to break anything. One of the changes was to add a parameter to proc, which pushes a new parameter into the method from which it is called. I coded it like this:

Optional BackReferenceID As String = String.Empty

But I got a syntax error "Constant expression is required." I guess String.Empty is non-deterministic??? Anyway, it seems like a bug. The workaround is of course to use double quotes.

View 1 Replies

C# - Set System.nullable Of Datetime As An Optional Parameter In A Subroutine?

Nov 13, 2011

I tried the following, but i get the error

constant expression is required
Public Sub ExampleSub(ByVal Test as string,
Optional ByVal fromDate As System.Nullable(Of DateTime) = Date.Today)
'A Great sub!

[Code].....

View 3 Replies

Optional Parameter Not Working When Trying To Pass Null Value To Database?

Apr 10, 2009

I am hardcoding an insert statement to a database, based on certain details a user enters into a windows form. The form has a few textbox and datetimepicker controls for the purpose. This form enters a single row in a single table in the database.The table has a few possible null columns defined, in those cases where the user does not have any data for those columns at that particular time.

I have to provide controls for passing data to those null columns nevertheless. In my case, I have two such columns that accept null values, and two corresponding controls - a textbox and a datetimepicker. The datetimepicker has a checkbox added to it so that if it is supposed to be null it doesn't pass the default current date value, and remains unchecked to explicitly specify that it is supposed to be null. By default it is unchecked.

My code is structured as follows:

Form1:
'the sub referenced here resides in a dll file in my dataaccesslayer code, and in my actual example is referenced properly.
'I have shortened the code here for simplicity

[code]....

Now it gives me an error whenever the code comes to the executenonquery(), and says something to the tune of "SqlDateTimeOverflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."

I think the value of 'Nothing' from the subprocedure's paramter is not being assigned to the sqlcommand's parameter as a database NULL, which is what I need to pass to the database.I know instead of using optional parameters I can easily create overloaded subprocedures where one sub allows not passing values where the column(s) is supposed to null and other overloaded subs permit combinations of which column(s) are null or not. But it is simple as long as there is just one, or at the most two null columns in a table. If I have dozens of null values in a table that the user can choose to enter or not in a data entry form?

View 7 Replies

Specify DEFAULT For Optional Parameter To Stored Procedure Wrapper Function?

Sep 18, 2009

My problem is this (apologies if this is a little long ... hang in there):I can define a function in VB.NET with optional parameters that wraps a SQL procedure:

Sub Test(OptionalByVal Arg1 As Integer _
Optional ByVal Arg2 As Integer _
Optional ByVal Arg3 As Integer

[code].....

View 7 Replies

.net - Passing Data To ASP.NET Webservice Using JSON?

Jun 22, 2010

I have successfully returned data from a ASP.Net webservice in JSON format (using a service method that required no parameters) but have struggled with making a webservice call that requires a parameter.

Webservice:

[Code]...

View 1 Replies

Create A Nullable Optional Numeric (integer/double) Parameter In Program?

Jan 18, 2010

How can I create a nullable numeric optional parameter in VB.NET?

View 3 Replies

Call Any Webservice By Passing To The Stored Procedure?

Oct 26, 2010

I would like to create a stored procedure that will call any webservice by passing to the stored procedure the webservice name/url and its parameters. I would like this instead of adding web refference each webservice one by one.

View 7 Replies

Error When Passing Quotes To Webservice By AJAX

Dec 27, 2010

I'm passing data using .ajax and here are my data and contentType attributes[code]...

View 1 Replies

Passing An Array Of Strings To A Webservice As Parameters?

Jul 26, 2011

I have created a webservice in VB.NET

<WebMethod(Description:="This
method will return object Values (in an array of String)for all objects (in an array og String)",
Enablesession:=False)>

[Code]....

Error 1 Value of type '1-dimensional array of String' cannot be converted to 'TestUse_SEdkVistaWebService.JF_WebService.ArrayOfString'

View 4 Replies

Stream Datatype And That Does Not Work As A Parameter On A Webservice

May 25, 2010

I'm new to webservices and xml.I've been given the task of creating a webservice with a method called UploadData. UploadData(Username as string, Pwd as string, XMLdata as String)The XMLData will be xml data 2-5mb.Is String the best data type?I've tried the stream datatype and that does not work as a parameter on a webservice.

View 2 Replies

ITextSharp - Calling AddImageToPage() With The The Optional Pages Parameter Will Add The Image To All Pages Though?

Dec 20, 2011

I am using Stanav's PdfManipulation2.AddImageToPage(..., Pages) for iTextSharp library (v5.1.3) and was not able to add the image to specific pages: e.g. to add to only page 1 and 3 of a five pages PDF

Dim Pages() As Integer
Pages = New Integer() {1, 3}
PdfManipulation2.AddImageToPage(..., Pages)

Calling AddImageToPage() with the the optional Pages parameter will add the image to all pages though.

View 14 Replies

Pass An Optional Parameter To A Function Of Type System.Drawing.Color - Error "Constant Expression Is Required"

Mar 22, 2012

I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.

[Code]...

View 14 Replies

Passing A Parameter Containing '&'

Feb 16, 2012

I am calling a crystal xi report from a windows form and passing 2 date parameters and a customer name. In some cases this customer name contains '&' eg Brown & Williams

In these cases my report fails and errors. if the name doesn't contain '&' it works. How can I pass the parameter with a & in it ?

View 2 Replies

Passing A Parameter To A Dataset

Apr 26, 2011

I created a dataset that is getting data from an access database. Now i would like to go further and make the dataset query accept a parameter from a form datepick value. the query in my table adapter I have changed it as follows to accept a parameter on date1.[code]The code I am using in my form is as below. I get a null reference exception on the second line(Object reference not set to an instance of an object). it seems as if my selectCommand is bringing nothing.[code]

View 4 Replies

Passing A Parameter Value To DataSet.XSD?

Jun 2, 2012

I have a bound DataGridView (dgvBuild) that contains data based on a "ProductID" that is derived from selecting the value from a ComboBox. How do I pass the ComboBox Value to the DataAdapter to retrieve records to reload the dgvBuild? Below is the code for theDataAdapter.This is the line that was created when I bound the DataGridView to a DB Table.

View 8 Replies

Passing An Event As A Parameter

Jun 10, 2011

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, then set the handler again. I'm doing this for several different events and event handlers, so I've decided to write a function that does this. As an example, let's say I have a combobox in my code called combobox1, and I have the handler called indexChangedHandler. In several places of my code, I have the following two lines:[code]Now, I don't want to keep on repeating the above two lines of code (or similar) all over my program, so I'm looking for a way to do this:[code]So far, the "evt as Event" part of the argument of the setHandler function is giving an error. Any ideas on the right way to do this will be very welcomed.

View 2 Replies

Passing An Event As A Parameter?

Nov 10, 2010

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, then set the handler again. I'm doing this for several different events and event handlers, so I've decided to write a function that does this.

As an example, let's say I have a combobox in my code called combobox1, and I have the handler called indexChangedHandler. In several places of my code, I have the following two lines:

RemoveHandler combobox1.SelectedIndexChanged, AddressOf indexChangedHandler
AddHandler combobox1.SelectedIndexChanged, AddressOf indexChangedHandler

Now, I don't want to keep on repeating the above two lines of code (or similar) all over my program, so I'm looking for a way to do this:

Private Sub setHandler(evt As Event, hndler As eventhandler)
RemoveHandler evt, hndler
AddHandler evt, hndler
End Sub

so that everywhere where those two lines of code(or similar) occur in my program, I can just replace them with:

setHandler(combobox1.SelectedIndexChanged, AddressOf indexChangedHandler)

So far, the "evt as Event" part of the argument of the setHandler function is giving an error.

P.S I've asked this question on a couple of other forums and keep getting asked why I would want to set the handler immediately after removing it. The reason is because dynamically adding an event handler n-times causes the handler to be executed n-times when the event occurs. To avoid this, i.e to ensure that the handler is executed just once when the event occurs, I first remove the handler each time I want to add the handler dynamically.

You might be asking why the handler would be added several times in the first place... The reason is because I add the handler only after a particular event, say E1, in my form has occured (I add the handler within the handler of event E1). And event E1 can occur several times within my form. If I do not remove the handler each time before adding it again, the handler gets added and thus executed several times.

Whatever the case, the processing occuring within the function is not of ultimate importance to me at this time, but rather just the means of passing an event as a parameter.

View 3 Replies

Passing Delegate As Parameter

Nov 6, 2010

I'd like to create a function myFunc with one parameter, which is a delegate. I should be able to call it with a delegate as parameter.E.g.[code]But how do I code myFunc, in other words, how do I enable myFunc to have it passed a delegate so that it can be called using myFunc(addressof test Func)?

View 4 Replies

VS 02/03 Passing Array As A Parameter?

Nov 16, 2010

I'm wondering if this sort of thing is possible in VB.NET.. say I have a routine which accepts an integer array, defined as:

Sub WriteTable(iRows As Integer, arrColumns As Integer())
The arrColumns parameter is an integer array of column widths.
I can pass a value by doing this:

[code]....

View 11 Replies

.Net With Passing Parameter To Crystal Report?

Dec 12, 2009

sample code for passing parameter to crysatl report dynamically in vb.net ...?

View 2 Replies

Call VBA Function With Parameter Passing

Dec 29, 2008

I wrote vba function in excel and I want to call this function in vb.net with parameter passing.

View 2 Replies

Error On Passing Date Parameter

Jul 24, 2010

I am getting error when debugging a project. The error is as below,

"FormatException was unhandled

String was not recognized as a valid DateTime."

Highlighting the following line

[code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved