Solved

error with substring

Posted on 2016-08-13
4
37 Views
Last Modified: 2016-08-17
hi,

I have a store procedure that returns a variable, the value is "dup", or NULL


in the asp.net page, I have an if-else

if (returnVal.ToString().Substring(0, 3) == "dup")
something
else
something

I am getting the error as seen below, am I missing something?  thanks

startIndex cannot be larger than length of string. Parameter name: startIndex

thanks
0
Comment
Question by:mcrmg
  • 2
4 Comments
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41755190
Wrap it in a  if (returnVal.ToString.length > 0) conditional.
0
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
ID: 41755242
You could use StartWith?
Ref: https://msdn.microsoft.com/en-us/library/baketfxw(v=vs.110).aspx

The code will be something like
if (returnVal.ToString().StartsWith("dup"))
  something
else
  something

Open in new window

0
 

Author Comment

by:mcrmg
ID: 41755408
thank you very much
0
 

Author Closing Comment

by:mcrmg
ID: 41759207
thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question