我连接的数据库是.dbf文件
string insertSQL = "insert into [sg0510wyys.dbf] (mondate,stname,w_temp) " +"VALUES (?, ?, ?)";OdbcCommand insertCMD = new OdbcCommand(insertSQL, cnn);
da.InsertCommand = insertCMD;
da.InsertCommand.Parameters.Add("@mondate", OdbcType.DateTime);
da.InsertCommand.Parameters["@mondate"].SourceColumn="mondate";
da.InsertCommand.Parameters.Add("@stname", OdbcType.VarChar);
da.InsertCommand.Parameters["@stname"].SourceColumn="stname";
da.InsertCommand.Parameters.Add("@w_temp", OdbcType.Decimal);
da.InsertCommand.Parameters["@w_temp"].SourceColumn="w_temp";
da.Fill(ds,"table1");
this.dataGrid1.DataSource=ds.Tables["table1"].DefaultView;
====================================================================
DataAdapter的insetcommand,updatecommand,selectcommand,deletecommand都已写好,
数据库中的w_temp字段是数字类型decimal
问题是当我在dataGrid中新添数据后,用update不能将数据写入数据库中,因为@w_temp的值通过sourcecolumn取得的值是字符串(虽然定义为decimal,但从DataTable中读出就为字符串了),而在前面的insert语句中VALUES (?, ?, ?)的第三个参数?必须为decimal才能插入到数据库中,
请问如何将如何办,转换类型????????在线等待!!!!
string insertSQL = "insert into [sg0510wyys.dbf] (mondate,stname,w_temp) " +"VALUES (?, ?, ?)";OdbcCommand insertCMD = new OdbcCommand(insertSQL, cnn);
da.InsertCommand = insertCMD;
da.InsertCommand.Parameters.Add("@mondate", OdbcType.DateTime);
da.InsertCommand.Parameters["@mondate"].SourceColumn="mondate";
da.InsertCommand.Parameters.Add("@stname", OdbcType.VarChar);
da.InsertCommand.Parameters["@stname"].SourceColumn="stname";
da.InsertCommand.Parameters.Add("@w_temp", OdbcType.Decimal);
da.InsertCommand.Parameters["@w_temp"].SourceColumn="w_temp";
da.Fill(ds,"table1");
this.dataGrid1.DataSource=ds.Tables["table1"].DefaultView;
====================================================================
DataAdapter的insetcommand,updatecommand,selectcommand,deletecommand都已写好,
数据库中的w_temp字段是数字类型decimal
问题是当我在dataGrid中新添数据后,用update不能将数据写入数据库中,因为@w_temp的值通过sourcecolumn取得的值是字符串(虽然定义为decimal,但从DataTable中读出就为字符串了),而在前面的insert语句中VALUES (?, ?, ?)的第三个参数?必须为decimal才能插入到数据库中,
请问如何将如何办,转换类型????????在线等待!!!!
解决方案 »
- [原创]C# socket 多线程多管道可断点传送大文件(附单线程单管道传送)
- [求助] 插入数据时dataGridView控件同步显示数据
- vs2005bug--fileSystemWatcher为何执行两次?
- 问一个关于文本框和按钮焦点的问题
- C#实现Telnet客户端功能
- 各位,有一个问题一直困饶着我,大家出点意见~~让我有一选择~~~!!!
- Visual Studio 2008发现疑问求解
- 请问.netc# 怎样让.cs里的变量写到aspx里的html里
- 动态生成的DataTemplate,如何为其的控件绑定事件?
- 如何从web页TreeView中获得一个节点的值
- 请问一个有关load_page的问题
- 分不多了50分跪求一个进度条问题~~~~~~~~~~~~~~~~~~~~~~~~~~
da.InsertCommand.Parameters["@w_temp"].value来赋值,
?这个参数获得是字符串,
能不能通过
string insertSQL = "insert into [sg0510wyys.dbf] (mondate,stname,w_temp) " +"VALUES (?, ?, ?)";
convert(decimal,?)
jxufewbt(我的目标是5星) :
两位高手,Convert.ToDecimal()要放在哪里,具体点行吗?