数据类型转换 [英] datatype conversion
本文介绍了数据类型转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在执行插入查询之前在c#编码中使用convert方法将货币转换为字符串
how to use convert method in the c# coding to convert money to string before executing the insert query
推荐答案
串联字符串值时,您可能希望查看参数化查询,这将使您可以按原样使用值,而无需将其强制转换为字符串,同时还可以减小sql注入攻击的范围.
使用SQL参数解决临时性能问题 [ SQL注入攻击 [
If you''re doing inserts into a database by concatenating string values you may want to look at parameterized queries instead, this would allow you to use the values as they are without casting them to strings while also reducing the scope for sql injection attacks.
Use SQL Parameters to Overcome Ad Hoc Performance Issues[^]
SQL injection attacks[^]
双精度字符串
双钱= 1144.50
字符串smoney = money.toString();
字符串加倍
money = convert.todouble(smoney);
double to string
double money=1144.50
string smoney=money.toString();
string to double
money=convert.todouble(smoney);
怎么样:
How about something like:
float foo = 1.23;
string ba = foo.ToString();
这篇关于数据类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文