Hi,
I am using vb.net and I would like to define one of my function parameters
to have a default value of null (in this case an sqltranaction object)
however I am having a great deal of trouble doing this.
my (incorrect) function declaration is below and I would appreciate somebody
pointing out my error.
Public Function EnterPractice(ByVal strPracticeName As String, ByVal
strUserName As String, ByVal objTran As SqlTransaction = dbnull) As Integer
Also, how would I explicitly pass a null argument to the function.
many thnaks in advance.
martin. 3 1569
Try this:
Public Function EnterPractice(ByVal strPracticeName As String, ByVal
strUserName As String, Optional ByVal objTran As SqlTransaction = Nothing)
As Integer
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"martin" <St**************@yahoo.com> wrote in message
news:uQ*************@TK2MSFTNGP10.phx.gbl... Hi,
I am using vb.net and I would like to define one of my function parameters to have a default value of null (in this case an sqltranaction object)
however I am having a great deal of trouble doing this.
my (incorrect) function declaration is below and I would appreciate
somebody pointing out my error.
Public Function EnterPractice(ByVal strPracticeName As String, ByVal strUserName As String, ByVal objTran As SqlTransaction = dbnull) As
Integer
Also, how would I explicitly pass a null argument to the function.
many thnaks in advance.
martin.
"martin" <St**************@yahoo.com> wrote in message news:uQ*************@TK2MSFTNGP10.phx.gbl... Hi,
I am using vb.net and I would like to define one of my function parameters to have a default value of null (in this case an sqltranaction object)
however I am having a great deal of trouble doing this.
my (incorrect) function declaration is below and I would appreciate somebody pointing out my error.
Public Function EnterPractice(ByVal strPracticeName As String, ByVal strUserName As String, ByVal objTran As SqlTransaction = dbnull) As Integer
I have no experience with vb.net, but I guess you need "DBNull.Value" here.
(DBNull is the class, DBNull.Value is an ("the") instance) Also, how would I explicitly pass a null argument to the function.
Just write "null" as the argument (by the way: "null" is NOT equal to "DBNull.Value")
Integer res = EnterPractice("thePracticeName", "theUserName", null)
(or should the C# "null" be translated in vb as "Nothing" ??)
many thnaks in advance.
martin.
Thanks guys
cheers
martin
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl... "martin" <St**************@yahoo.com> wrote in message
news:uQ*************@TK2MSFTNGP10.phx.gbl... Hi,
I am using vb.net and I would like to define one of my function
parameters to have a default value of null (in this case an sqltranaction object)
however I am having a great deal of trouble doing this.
my (incorrect) function declaration is below and I would appreciate
somebody pointing out my error.
Public Function EnterPractice(ByVal strPracticeName As String, ByVal strUserName As String, ByVal objTran As SqlTransaction = dbnull) As
Integer
I have no experience with vb.net, but I guess you need "DBNull.Value"
here. (DBNull is the class, DBNull.Value is an ("the") instance) Also, how would I explicitly pass a null argument to the function.
Just write "null" as the argument (by the way: "null" is NOT equal to
"DBNull.Value") Integer res = EnterPractice("thePracticeName", "theUserName", null)
(or should the C# "null" be translated in vb as "Nothing" ??)
many thnaks in advance.
martin.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Senthilvel |
last post by:
Hi folks,
My friend tells that the following function declaration is illegal.
void Foo(const string& strData = "Default");
My friend argues that it is not legal to provide a default value for...
|
by: Vic Y |
last post by:
Hi,
I am trying to call a user defined function(UDF) from a stored proc,
using a default parameter in the called UDF (e.g. @bid_price_type int
= 0 ). However the calling stored proc complains...
|
by: The Plankmeister |
last post by:
Hi...
I have a query which I'm accessing through PHP as a stored procedure.
However, I need to be able not to pass a couple of parameters in certain
situations. When I do this, I get an error:
...
|
by: Marc DVer |
last post by:
I am trying to create a query that can be loaded as a querydef object
but not having to assign values to the parameters if I don't want to.
Normally when using a parameter query in VBA my code...
|
by: dbuchanan |
last post by:
Hello,
Is this a bug?
Is there some kind of work around?
I want to add default values for a few columns in my datagridview
I found the "DefaultValuesNeeded" event for the datagridview
I...
|
by: syntego |
last post by:
We commonly use triggers to log changes to our main tables to
historical log tables.
In the trigger, we create a concatenated string of the old values by
casting them as follows:
...
|
by: asianmuscle |
last post by:
I am trying to learn RAII and some template techniques by writer a
smarter pointer class to manage the resource management. Since I find
that a lot of the resource management is kinda the same, I...
|
by: jryden |
last post by:
I can do this:
struct myInt
{
int i;
};
void func1(myInt &i = myInt());
but not this:
|
by: Gary Wessle |
last post by:
I have a method with the last arguments having defaults like this
void filing(long, double,
const myType& r_mo=NULL,
const herType& r_tr=NULL);
is that acceptable, if not how is it done?...
|
by: Clyde |
last post by:
Hi,
what i'm trying to do is:
/////////////// Code Start
template <class TType, int* p = 0>
class Template
{
public:
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |