.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

convert result to positive if negative?

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net


i have a select statement below. The result of r1- @r1 may be positive or negative.

i want it to always result as positive, so it is a negative number then it to show the same number as positive. can i do this?


r1 = 7, @r1 = 4

r1 - @r1 = 3


if r1 = 5, @r1 = 6

r1 = @r1 = -1, but i want this to be 1, because i am trying to work out the difference between the two numbers.

can this be done within a select statement? my select statement is:

SELECT     imageurl, (r1 - @r1)  AS difference

View Complete Post

More Related Resource Links

insufficient result space to convert uniqueidentifier value to char


Hi guys,

       Look, I've been trying to insert new values while I create a new user with a createuserwizard, but I've been getting this error over and over again:

"insufficient result space to convert uniqueidentifier value to char"

       The code that does it is the following:

  protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
TextBox UserNameTextBox = (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");

SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

MembershipUser User = Membership.GetUser(UserNameTextBox.Text);

object UserGUID = User.ProviderUserKey;

DataSource.InsertParameters.Add("UserId", UserGUID.ToString());


      But when I debug, the error is thrown before reaching the previous code, so I suppose the error is in the SqlDataSource, look:

      <asp:SqlDataSource ID="InsertExtraInfo" runat="server" Co

query negative and positive values and not their boolean counterpart

Good Day Need help.. I have this simple table, CREATE TABLE [dbo].[sample] ( [id] [int] NOT NULL , [number] [int] NULL , ) ON [PRIMARY] i wanted to make a select query that would display two columns(positive, negative) the sql statement that i made: "select (sample.number > 0) as positive, (sample.number < 0) as negative from sample " what happened is that, it displays the boolean counterpart and not the value.. I wanted to show this kind of data: substitute the "False" value into 0 and "-1/true" value with the exact absolute numerical value.   |debit||credit| |   0   ||  200 | |   0   ||  57   | |   50 ||  0     |   is this possible?  

Showing positive/negative sign in the output of Int32.ToString(string)

Hi,   Now this may be really simple but I'm unable to make it work or find it in MSDN. What is the format specifier for showing +/- sign of an Int32? I have tried "+0", "-0" and "+-0" and all of them give wrong results for either positive or negative or both kind of values. Note: The specifier should return "+0" for 0.

Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

is it possible to convert whole visual studio 2008 web site project to visual studio 2010 web site p


is it possible to convert whole visual studio 2008 web site project to visual studio 2010 web site project


my current project references




i have a very annoying iis problem

iis server stops working until app pool is recycled


i am hoping that new visual studio (net framework 4.0) may solve this very annoying unsolveable problem


Convert excel file into xml


Hai, I have two columns with id,name in the excel sheet.I want to convert into xml file in the below format

<?xml version="1.0" encoding="utf-8"?>

<guide xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Boat id="1"> <name> Copper Kettle </name> </Boat> <Boat id="2"> <name> Copper Penny </name> </Boat> <Boat id="3"> <name> Copperhead </name> </Boat> <Boat id="4"> <name> Coppertone </name> </Boat> <Boat id="5"> <name> Copy Boy </name> </Boat> </guide>

suggest me with sample code in ASP.NET. Thanks


convert SQL data to EDI 835 file


I was assigned to create a app to convert SQL data to EDI 835 file. (Electronic Data Interchange file for Health Care Claim Payment/Advice,  outbound process only).

Can someone help me where to start?

Active Directory and .NET: paging the search result

Hi everybody!

I have a question about Active Directory in .NET
For my project I need to fetch results from Active Directory search page by page, because later I would need to bind it to the pageable DataGrid.

I tried to use .NET library DirectoryServices for that, but paging provided by this library is transparent to the user and is used only to increase the efficiency of searching, when results are too big. I.e. I cannot tell the DirectorySearcher to give me first page, then the next or previous page, it returns me all resulting pages in one bundle.

However, what I need is to explicitely get page after page directly from the AD searcher and to be able to go at least one page forward or backward.

The solution with copying all results to the DataBase and then do the paging is not accepeted by the clent, since it is too inefficient. And since it's a Web app, I cannot keep results in memory either.

I found some hints about COM Interface, but I could not find good and detailed examples or explanations. I aslo found this line of code: DirectoryServices.Interop.IDirectorySearch.ExecuteSearch(), but I don't know which libraries should i add to be able to compile this code.

If somebody could help me out with that problem, any suggestion is welcome, 'cause this issue is eating me alive :)

Thank you!

Convert WCF service to self hosting application


 I created project as a  WCF Service application and now according to recuriment that needs to be converted as a self hosting application

How can i do this?

Converting WCF service app to Self hosting app?

How to Convert HTML to Image


 HI all,

I was struggling for the process/code to convert html to image. Please suggest any tutorials for this. And also any code help greatly appreciated.


thanks and regards,



convert jpeg to tiff


Hi all,

I need to comvert jpeg to tiff using c#.net

I have achieved this but problem is image size is increasing drastically. eg: 25 kb of jpeg image is converted to 650 kb of tiff image.

What should be done to have the same image size as of original or atleast double the image size as of original.

Please suggest me. Thanks in advance.

Easy image processing(grayscale, sepia, negative, resize, brightness, contrast and opacity)

Howdie y'all,

I see a lot of questions in this forum about resizing images. Recently I created a code sample(with downloadable webapp), right here.

The class (downloaded or created) allows for very fast and easy processing of your images. And a lot of problems over here can be solved by simply using that class. I thought it might help to mention the code sample in this forum as well.



Crystal Report vs 2003 convert to vs 2008 parameter problem


Hi friend,

I have a project develop with Visual Studio 2003, when i convert the project to Visual Studio 2005 is work well. But when i convert to Visual Studio 2008, the crystal report when have pass parameter will prompt the parameter field to re-type then show the report.

But in this converted project i create a new report and pass the parameter is ok. That means i wan re-do all report @.@??

Does someone can help me solve this problem??

Thank you

Convert Cold Fusion to VB.Net


Could someone please help me convert the following code to VB.Net?  

<cfif isdefined("form. backgroundCheckResult")> 


                <cfif processingStatus eq "success">

                                <cfoutput>success </cfoutput>





Cannot convert type 'object[]' to 'byte[]'


I am doing this .. and i want to convert object array to byte array. How should I do that?

Object[] myVal = um.myData;

Byte[] byteArray = (Byte[])myVal;

Does the use of regions have a negative impact on the application?


Does the use of regions have a negative impact on the execution of the code?  Are there any negative side effects from using these?

Are they completely ignored at runtime?

Want to convert the code from c# to asp

  1.  WebRequest myWebRequest = WebRequest.Create(URL);  
  2.                 WebResponse myWebResponse = myWebRequest.GetResponse();  
  3.                 Stream ReceiveStream = myWebResponse.GetResponseStream();  
  4.                 Encoding encode = System.Text.Encoding.GetEncoding("utf-8");  
  5.                 StreamReader readStream = new StreamReader(ReceiveStream, encode);  
  6.                 string strResponse = readStream.ReadToEnd();  
  7.                 Response.Write("Response from site"
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend