转换数据类型 [英] conversion Data Type

查看:72
本文介绍了转换数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的方法,即GetAmountInBank,它在查询的帮助下从银行表中获取金额,该方法在下面提到。



here is my method i.e GetAmountInBank which getting amount from bank table with the help of Query which is mentioned below the method.

string GetAmountInBank(string Bank)







这是我的查询:




here is my Query:

strSQL = "select Sum(AmountinBank) from BankAccount,accountitem,accountcategory where accountitem.ItemcatID=accountcategory.CategoryID and BankAccount.ItemID=accountitem.ItemID   and accountcategory.IsExpense=0 and BankId like '" + Bank + "'";







这里是完整代码:






Here is complete Code:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;

public partial class Jqurey : System.Web.UI.Page
{
    DBconn db = new DBconn();
   // Security s = new Security();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
           // user myUsers = new user();
            Response.Expires = -1;
            //required to keep the page from being cached on the client's browser

            Response.ContentType = "text/plain";
            string BankID = Request.QueryString["BankID"].ToString();

            string BankAmount = GetAmountInBank(BankID);
            Response.Write(BankAmount);

           // Session["BankAmount"] = BankAmount;

        }

    }
    string GetAmountInBank(string Bank)
    {
        string strSQL = "select Sum(AmountinBank) from BankAccount,accountitem,accountcategory  where accountitem.ItemcatID=accountcategory.CategoryID  and BankAccount.ItemID=accountitem.ItemID   and accountcategory.IsExpense=1 and BankId like '" + Bank + "'";
        string totalExp = db.selectquery_One(strSQL).ToString();

        if (totalExp == "")
        {
            totalExp = "0";
        }


        strSQL = "select Sum(AmountinBank) from BankAccount,accountitem,accountcategory where accountitem.ItemcatID=accountcategory.CategoryID  and BankAccount.ItemID=accountitem.ItemID   and accountcategory.IsExpense=0 and BankId like '" + Bank + "'";

        string totalDep = db.selectquery_One(strSQL).ToString();

        if (totalDep == "")
        {
            totalDep = "0";
        }

//Having Problem in this Line

        double dResult = Convert.ToDouble(totalDep) - Convert.ToDouble(totalExp);

        return dResult.ToString();
    }


}

推荐答案

数据类型转换。



将值从一种数据转换为另一种数据有时是有益的。每个转换函数都将其参数转换为其数据类型中的等效表示。转换函数包括int(),float(),char(),byte()等。





Datatype Conversion.

It is sometimes beneficial to convert a value from one type of data to another. Each of the conversion functions converts its parameter to an equivalent representation within its datatype. The conversion functions include int(), float(), char(), byte(), and others.


// The next line is needed if running in JavaScript Mode with Processing.js
/* @pjs font="Georgia.ttf"; */

size(640, 360);
background(0);
noStroke();

textFont(createFont("Georgia",24));

char c;    // Chars are used for storing alphanumeric symbols
float f;   // Floats are decimal numbers
int i;     // Integers are values between 2,147,483,647 and -2147483648
byte b;    // Bytes are values between -128 and 128

c = 'A';
f = float(c);      // Sets f = 65.0
i = int(f * 1.4);  // Sets i to 91
b = byte(c / 2);   // Sets b to 32

//println(f);
//println(i);
//println(b);

text("The value of variable c is " + c, 50, 100);
text("The value of variable f is " + f, 50, 150);
text("The value of variable i is " + i, 50, 200);
text("The value of variable b is " + b, 50, 250);







处理由Ben Fry和Casey Reas发起。它是devel




Processing was initiated by Ben Fry and Casey Reas. It is devel


这篇关于转换数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆