Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual c 2010显示从sql数据库到标签的余额_C# - Fatal编程技术网

C# Visual c 2010显示从sql数据库到标签的余额

C# Visual c 2010显示从sql数据库到标签的余额,c#,C#,我想显示从数据库到标签的余额 这是我到目前为止得到的代码 SqlDataReader readbalance; sqlCommandbalance.Connection.Open(); sqlCommandbalance.CommandText = "SELECT * FROM Accounts WHERE accountID = '" + dataSet11.Tables[0].Rows[0]["accountID"] + "'"; read

我想显示从数据库到标签的余额

这是我到目前为止得到的代码

SqlDataReader readbalance; 

        sqlCommandbalance.Connection.Open();
        sqlCommandbalance.CommandText = "SELECT * FROM Accounts WHERE accountID = '" + dataSet11.Tables[0].Rows[0]["accountID"] + "'";
        readbalance = sqlCommandbalance.ExecuteReader();
        string balanceDB = null;
        while (readbalance.Read()) 
        {
            balanceDB = readbalance["balance"].ToString();
        }
        sqlCommandbalance.Connection.Close();
        balanceShow.Text += "" + balanceDB.ToString();;
我在这条线上遇到了一个问题 sqlCommandbalance.CommandText=从accountID='+dataSet11.Tables[0].行[0][accountID]+'的帐户中选择*


一直说cnt find row位于位置0,但我正在commandtext数据集11上测试这段代码。表[0]。行[0][accountID]不确定它是否正确。这意味着accountID、balance、overdraftLimit中的一个或多个参数必须是整数,并且您正在设置它的字符串值。

使用int.ParsebalanceShow.Text

只是猜测一下,购买你需要的东西可能是这样的:

SqlDataReader readdata;
sqlCommandCheckBalance.Parameters["@accountID"].Value = accountID;
sqlCommandCheckBalance.Connection.Open(); 
readdata = sqlCommandCheckBalance.ExecuteReader();
while (readdata.Read())
{
    balanceShow.Text += " " + readdata["balance"].ToString();
}

accountID-INT,balance-money-overdraftlimit-money,您正在设置balanceShow.Text的全部值?balanceShow.Text的值是多少?它看起来像一个非整数,这意味着您不能将其转换为整数,也不能将此值设置为这些参数。所以,您需要做的是,将整数值(如12)设置为@accountID,将双倍值(如12.5)设置为balance和overdraftLimit参数。