当我选择记录"3"更新时,我需要今天更改日期 [英] when i am select record '3' update i need change the date today

查看:69
本文介绍了当我选择记录"3"更新时,我需要今天更改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Id      Date
1   1/08/2012
2   13/08/2012
3   14/08/2012


当我选择记录"3"更新时,我今天需要更改日期


when i am select record ''3'' update i need change the date today

推荐答案

我想您的下拉列表中包含值1,2,3等ID列.,


在您的下拉列表中,所选索引已更改事件,

编写新的sql命令以更新

I guess you are having dropdown with values 1,2,3 etc which is ID Column.,


In your dropdown selected index changed event,

Write a new sql command to update

SqlCommand cmd=new SqlCommand("update tbl set Date=@Date where Id=@Id",connection1);
cmd.Parameters.AddWithValue("@Date",DateTime.Now);
cmd.Parameters.AddWithValue("@Id",Convert.ToInt32(cmb.SelectedValue.ToString()));
connection1.Open();
cmd.ExecuteNonquery();
connection1.Close();


这篇关于当我选择记录"3"更新时,我需要今天更改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆