473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

check for function return type

I have a function that returns a dataset or a boolean depending upon whether
a record was found. I can check for the string value of the return type, but
i don'r think this is the right way to do it what is the correct method?
any help would be appreciated.
(hey, i'm actually learning how to do this "-------"!
FUNCTION:
' this function will return the a dataset with the current user if
the loogin was successful else if will return a false
Dim DsUser1 As dsUser = New dsUser
Me.SqlDataAdapter1.SelectCommand.Parameters(1).Val ue = thsUserID
Me.SqlDataAdapter1.SelectCommand.Parameters(2).Val ue = thsPassword
Me.SqlDataAdapter1.Fill(DsUser1.usr)
If DsUser1.usr.Count = 0 Then
Return False
Else
Return DsUser1
End If
End Function
function call
If IsValid Then
Try
Dim us As UserServices = New UserServices
Dim usrResult As Object
usrResult = us.fn_Isvalid(Me.txtUserID.Text,
Me.txtPassword.Text)
Me.lblMSG.Text = usrResult.GetType.ToString()
If usrResult.GetType = System.Boolean
Me.lblStatus.Text = User not valid
ELSE
Me.lblStatue.text = usrREsult.usrUserID
End If

Catch ex As Exception
.......
End Try
End If

thanks
kes
Nov 19 '05 #1
4 1633
Your function should not be declared as Object. If Option Strict is not on -
turn it on. And always keepp it on.

You can declare the function as returning a dataset, and then return
Nothing, if no rows came back. You will just have to test the result of the
call to see if it's Nothing. If it is, no user was found, otherwise you can
safely use the dataset that was returned.

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I have a function that returns a dataset or a boolean depending upon
whether
a record was found. I can check for the string value of the return type,
but
i don'r think this is the right way to do it what is the correct method?
any help would be appreciated.
(hey, i'm actually learning how to do this "-------"!
FUNCTION:
' this function will return the a dataset with the current user if
the loogin was successful else if will return a false
Dim DsUser1 As dsUser = New dsUser
Me.SqlDataAdapter1.SelectCommand.Parameters(1).Val ue = thsUserID
Me.SqlDataAdapter1.SelectCommand.Parameters(2).Val ue = thsPassword
Me.SqlDataAdapter1.Fill(DsUser1.usr)
If DsUser1.usr.Count = 0 Then
Return False
Else
Return DsUser1
End If
End Function
function call
If IsValid Then
Try
Dim us As UserServices = New UserServices
Dim usrResult As Object
usrResult = us.fn_Isvalid(Me.txtUserID.Text,
Me.txtPassword.Text)
Me.lblMSG.Text = usrResult.GetType.ToString()
If usrResult.GetType = System.Boolean
Me.lblStatus.Text = User not valid
ELSE
Me.lblStatue.text = usrREsult.usrUserID
End If

Catch ex As Exception
......
End Try
End If

thanks
kes

Nov 19 '05 #2
thanks,
i was hoping for some flexability with return types but, well.........
thanks you again
kes

"Marina" wrote:
Your function should not be declared as Object. If Option Strict is not on -
turn it on. And always keepp it on.

You can declare the function as returning a dataset, and then return
Nothing, if no rows came back. You will just have to test the result of the
call to see if it's Nothing. If it is, no user was found, otherwise you can
safely use the dataset that was returned.

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I have a function that returns a dataset or a boolean depending upon
whether
a record was found. I can check for the string value of the return type,
but
i don'r think this is the right way to do it what is the correct method?
any help would be appreciated.
(hey, i'm actually learning how to do this "-------"!
FUNCTION:
' this function will return the a dataset with the current user if
the loogin was successful else if will return a false
Dim DsUser1 As dsUser = New dsUser
Me.SqlDataAdapter1.SelectCommand.Parameters(1).Val ue = thsUserID
Me.SqlDataAdapter1.SelectCommand.Parameters(2).Val ue = thsPassword
Me.SqlDataAdapter1.Fill(DsUser1.usr)
If DsUser1.usr.Count = 0 Then
Return False
Else
Return DsUser1
End If
End Function
function call
If IsValid Then
Try
Dim us As UserServices = New UserServices
Dim usrResult As Object
usrResult = us.fn_Isvalid(Me.txtUserID.Text,
Me.txtPassword.Text)
Me.lblMSG.Text = usrResult.GetType.ToString()
If usrResult.GetType = System.Boolean
Me.lblStatus.Text = User not valid
ELSE
Me.lblStatue.text = usrREsult.usrUserID
End If

Catch ex As Exception
......
End Try
End If

thanks
kes


Nov 19 '05 #3
how would you check for nothing?
thanks again!!!
kes

"Marina" wrote:
Your function should not be declared as Object. If Option Strict is not on -
turn it on. And always keepp it on.

You can declare the function as returning a dataset, and then return
Nothing, if no rows came back. You will just have to test the result of the
call to see if it's Nothing. If it is, no user was found, otherwise you can
safely use the dataset that was returned.

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I have a function that returns a dataset or a boolean depending upon
whether
a record was found. I can check for the string value of the return type,
but
i don'r think this is the right way to do it what is the correct method?
any help would be appreciated.
(hey, i'm actually learning how to do this "-------"!
FUNCTION:
' this function will return the a dataset with the current user if
the loogin was successful else if will return a false
Dim DsUser1 As dsUser = New dsUser
Me.SqlDataAdapter1.SelectCommand.Parameters(1).Val ue = thsUserID
Me.SqlDataAdapter1.SelectCommand.Parameters(2).Val ue = thsPassword
Me.SqlDataAdapter1.Fill(DsUser1.usr)
If DsUser1.usr.Count = 0 Then
Return False
Else
Return DsUser1
End If
End Function
function call
If IsValid Then
Try
Dim us As UserServices = New UserServices
Dim usrResult As Object
usrResult = us.fn_Isvalid(Me.txtUserID.Text,
Me.txtPassword.Text)
Me.lblMSG.Text = usrResult.GetType.ToString()
If usrResult.GetType = System.Boolean
Me.lblStatus.Text = User not valid
ELSE
Me.lblStatue.text = usrREsult.usrUserID
End If

Catch ex As Exception
......
End Try
End If

thanks
kes


Nov 19 '05 #4
sorry, found my own answer
If usrResult Is Nothing Then
Me.lblStatus.Text = "user is not valid"
Else
Me.lblStatus.Text = usrResult.usr(0).usrLName
End If
IOU1!!!
thanks
kes

"WebBuilder451" wrote:
how would you check for nothing?
thanks again!!!
kes

"Marina" wrote:
Your function should not be declared as Object. If Option Strict is not on -
turn it on. And always keepp it on.

You can declare the function as returning a dataset, and then return
Nothing, if no rows came back. You will just have to test the result of the
call to see if it's Nothing. If it is, no user was found, otherwise you can
safely use the dataset that was returned.

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I have a function that returns a dataset or a boolean depending upon
whether
a record was found. I can check for the string value of the return type,
but
i don'r think this is the right way to do it what is the correct method?
any help would be appreciated.
(hey, i'm actually learning how to do this "-------"!
FUNCTION:
' this function will return the a dataset with the current user if
the loogin was successful else if will return a false
Dim DsUser1 As dsUser = New dsUser
Me.SqlDataAdapter1.SelectCommand.Parameters(1).Val ue = thsUserID
Me.SqlDataAdapter1.SelectCommand.Parameters(2).Val ue = thsPassword
Me.SqlDataAdapter1.Fill(DsUser1.usr)
If DsUser1.usr.Count = 0 Then
Return False
Else
Return DsUser1
End If
End Function
function call
If IsValid Then
Try
Dim us As UserServices = New UserServices
Dim usrResult As Object
usrResult = us.fn_Isvalid(Me.txtUserID.Text,
Me.txtPassword.Text)
Me.lblMSG.Text = usrResult.GetType.ToString()
If usrResult.GetType = System.Boolean
Me.lblStatus.Text = User not valid
ELSE
Me.lblStatue.text = usrREsult.usrUserID
End If

Catch ex As Exception
......
End Try
End If

thanks
kes


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jay | last post by:
Hi ! I am a beginner in PHP. Does anybody know how to check if an URL is alive or dead in PHP (not exist or server down...or whatever ) ? Any help would be appreciated ! Thanks ! Jay
3
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
1
by: Bjoern Jackschina | last post by:
Hello, until now I have not found the mistake that I made. My source code for checking how many checkboxes or radiobuttons are used: <script language="JavaScript"><!-- function pruefen(){return...
5
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab...
3
by: frizzle | last post by:
Hi there, I'm building a multi-language PHP/mySQL -site. I'm also building a CMS for the site. There are 5 languages. In the CMS fields for e.g. english bodytext are called (id=)...
5
by: eyoung | last post by:
I have a function to check a string to make sure it is 6 digites using the trigger onBlur="CkFrmt(this)" Problem is I've got 4 fields in a row...if I enter a wrong number in the first and hit tab...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
10
by: Matthias | last post by:
Dear newsgroup. I want to write a template function which accepts either integer or floating point numbers. If a certain result is not a whole number and if the template parameter is an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.