本文介绍了我想在数据表中添加新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据表是这样的
Dayid开始时间结束时间
1 10:00 12:00
2 11:00 1:00
3 9:00 5:00
我想更改Dayid和列.我想给天而不是dayid ..像1-sunday,2-monday ....像这样..我该怎么做..plz帮助我.....
My datatable is like this
Dayid Starttime EndTime
1 10:00 12:00
2 11:00 1:00
3 9:00 5:00
I want to change the column Dayid and .I want to give days instead of dayid..like 1-sunday,2-monday....like this..how can i do this..plz help me.....
推荐答案
yourdatatable.Columns["Dayid"].ColumnName = "YourDesiredName";
Then get days and add as its value for your row column with foreach loop:
foreach(DataRow myRow in table.Rows)
{
myRow[1]["YourDesiredName"] = "day";
}
ALTER TABLE ur_table_name
DROP COLUMN Dayid
然后再次添加->
then add it again-->
ALTER TABLE ur_tablename
ADD Dayid varchar(10)
之后,您可以将星期一,星期二放在........
after that u can put monday,tuesday.....
这篇关于我想在数据表中添加新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!