?
Solved

error with substring

Posted on 2016-08-13
4
Medium Priority
?
54 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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