如何使用c#在asp.net中将字符串转换为bigint [英] how to convert string to bigint in asp.net using c#

查看:413
本文介绍了如何使用c#在asp.net中将字符串转换为bigint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#在asp.net中将字符串转换为bigint。



我已将Refid视为Bigint。

所以,我想要将文本框值转换为BIGINT



how to convert string to bigint in asp.net using c#.

I have taken Refid as Bigint.
So,i want to convert textbox value to BIGINT

Query = "select * from demo where Refid=" + __________(TextBox1.Text);

推荐答案

您的查询将在没有任何转换的情况下正常工作。只需确保在发送到查询之前验证在文本框中输入的值。
You query is going to work just fine without any conversion. Just make sure that the value entered in the textbox is validated before sending to the query.


您好,



您可以使用以下转换内容。

Hi,

You can use the following things for conversion.
textboxvaluehere.ToInt64();
Convert.ToInt64(textbox value here);

Int64.Parse(textbox value here);
Int64.TryParse(your textbox value, out parameter);





使用这些方法中的任何一种,您将得到要解析的整数。但请记住,您的文本框包含有效输入。



谢谢



Use any one of these method and you will get the integer to be parsed. But remember that your textbox contains a valid input.

Thanks


最简单的方法是使用Convert.ToInt,例如从演示中选择*,其中Refid =+ Convert.ToInt64(TextBox1.Text);



但是,如果您不确定该字符串是否为整数,则可能会出现问题。

在这种情况下,您可以考虑使用 Int64.TryParse < a href =http://msdn.microsoft.com/en-us/library/system.int64.tryparse.aspx> [ ^ ]。
It is easiest to use Convert.ToInt e.g. select * from demo where Refid=" + Convert.ToInt64(TextBox1.Text); .

However, this can be a problem if you are not sure if the string is an integer.
In this case, you can consider using Int64.TryParse[^].


这篇关于如何使用c#在asp.net中将字符串转换为bigint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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