c# - npgsql 字符串到数字

标签 c# sql visual-studio-2010 npgsql

这是代码:

autoInsert.Parameters.Add(new NpgsqlParameter("price", NpgsqlDbType.Numeric));
autoInsert.Parameters[0].Value = txt_price.Text;
        con.Open();
        autoInsert.ExecuteNonQuery();
        con.Close();

当我执行查询时,它显示错误:“输入字符串的格式不正确。” 如何将该字符串转换为数字。 txt_price 是文本框。

最佳答案

autoInsert.Parameters[0].Value = ConvertToInt32(txt_price.Text); 

关于c# - npgsql 字符串到数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8896157/

相关文章:

c# - 如何知道 DateTime 是否在 C# 中的 DateRange 之间

c# - 将一组值发送到 Oracle 过程以在 WHERE IN 子句中使用

python - sqlite3.OperationalError : near "WHERE": syntax error (Python 2, sqlite3)

visual-studio-2010 - 将Visual Studio 2010 RC升级到RTM/零售/最终版

c# - 为一个元素设置样式表

c# - 测量页面加载时间?

mysql - 查找不仅仅是特定 SKU 的订单

mysql - 为什么 MySQL 要求参数按特定顺序排列?

.net - 人们期待 .Net 4.0 - 4.1 中的哪些功能

c# - 如何检查连接字符串是否有效?