插入中的字段类型更改 [英] field type change in insert
本文介绍了插入中的字段类型更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我有数据库访问权限,我有atable从gridview 3获取其数据字段是数字并接受双倍,当我传递值时字段类型变为文本
什么是错误的发生这是我的代码
hi everyone i have database access where i have atable which gets its data from gridview 3 of field are number and accept double when i pass value the fields type get change into text
whats the wrong that make happen this is my code
public void Addrep(string ReName, double Reprice, double Retotal, double Recount)
{
String str = " INSERT INTO Report ( Re_Name, Re_price, Re_total, Re_count ) values ('" + ReName + "','" + Reprice + "','" + Retotal + "','" + Recount + "' )";
OpenCnn();
//3- Open command option - cnn parameter is imporant
OleDbCommand cmd = new OleDbCommand(str, cnn);
cmd.ExecuteNonQuery();
//5 close connection
CloseCnn();
}
// the other part is
if (RowsCount != 0 || RowsCount != null)
{
repo.DeleteRe();
for (int i = 0; i < RowsCount; i++)
{
//this.dgvsell.Rows[i].Cells[2].Value.ToString()
repo.Insert(this.dgvsell[2, i].Value.ToString(),
Convert.ToDouble(dgvsell[4, i].Value),
Convert.ToDouble(dgvsell[5, i].Value),
Convert.ToDouble(dgvsell[6, i].Value));
}
}
我的字段是Re_Name文本,Re_price double,Re_total double, Re_count数字
插入它自动更改为
Re_Name文本,Re_price文本,Re_total文本,Re_count文本什么是最好的灵魂问题
and my fields are Re_Name text, Re_price double, Re_total double, Re_count number
in insert it changed automatically into
Re_Name text, Re_price text, Re_total text, Re_count text what is the best soulation for that problem
推荐答案
感谢所有我用params解决了它
thanks for all i have solved it using params
这篇关于插入中的字段类型更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文