如何改变绑定到数据库的numericUpDown值

ll821121 2009-04-12 07:39:05
程序如下:
numericUpDown.Enabled = true;
numericUpDown.Value = 5;
numericUpDown.Increment =0.01m;);//此处有问题吗
numericUpDown.ValueChanged+=new EventHandler(numericUpDown_ValueChanged);//此处有问题吗

private void btnOk_Click(object sender, System.EventArgs e)
{
SqlCeConnection conn = null;
try
{ conn = new SqlCeConnection(@"Data Source =\Program Files\RealtimeMonitor\realtimedata.sdf");
conn.Open();
String sql = "insert into AP([power02]) values ('" + this.numericUpDown.Value + "')";
SqlCeCommand cmd = new SqlCeCommand(sql, conn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch (SqlCeException sqlex)
{
foreach (SqlCeError sqlerror in sqlex.Errors)
{ MessageBox.Show(sqlerror.Message); }
}

finally { if (conn.State != ConnectionState.Closed) { conn.Close(); } }
this.Close();
}
private void numericUpDown_ValueChanged(object sender, EventArgs e)
{}
我用的是VS.net2005、SQL Mobile、Windows CE平台,想把控件numericUpDown的值存到数据库里,为啥实现不了自动增加值,就是实现不了Valuechanged属性。请大虾帮忙。AP是表名,power02是列名,
...全文
169 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkun_3yue3 2009-04-12
  • 打赏
  • 举报
回复
numericUpDown.Increment =0.01m;);//此处有问题吗
那半个括号是干啥的呀

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧