更新年份和月份 [英] update year and month

查看:86
本文介绍了更新年份和月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.....

非常紧急..............我怎么能只拿一年和一个月的部分它应该保存在月份和年份字段中的数据库分别.........当我在表单中输入日期时,它应该自动更新数据库中的年份和月份字段........在我的项目中我在每日,每月和每年的基础上绘制图表.....我得到了如何在日间绘制图表,但我不知道如何绘制图表的月和年基础可以任何人帮助我PLZ .... ......我正在使用vb6.0和后端ms访问........


i我正在使用adodc1 .........和当我在文本框中输入日期时,它存储在数据库中,但我想同时在不同的字段中存储数据库中的月份和年份.................... ..

在数据库中的日期格式是中期日期(2007年6月1日)



我的代码是这样的...... .......

展开 | 选择 | Wrap < span class =codeDivider> | 行号

解决方案

< blockquote>尝试将其用作SQL字符串。


sSQL =" INSERT INTO Table1(Month,Year)VALUES(''" &安培; m& "," &安培; y& "'')"


请记住不要在任何数字值周围加上引号。这可能包括年份,可能包括也可能不包括月份。



请记住不要在任何数值周围加上引号。这可能包括年份,可能包括也可能不包括月份。



当我运行它时会发出错误信息
运行时错误:3709

连接不能用于执行此操作。在此上下文中它已关闭或无效


展开 | 选择 | Wrap | 行号


hi......
Its very urgent.............. how can i take only the year and month part and it should save in the database in the month and year field separately......... when i enter the date in the form it should automatically update the year and month field in the db........ in my proj i am drawing a graph on daily, monthly and yearly basis..... i got how to draw a graph on day basis but i dont know how to draw a graph on month and year basis can any one help me plz.......... i am using vb6.0 and back end ms access........

i am using adodc1......... and when i enter the date in textbox it is storing in the database but i want to simultaneously store only month and year part in the database in different fields......................
in database the date format is medium date (1-jun-2007)


and my code is like that..........

Expand|Select|Wrap|Line Numbers

解决方案

try to use this as SQL string.

sSQL = "INSERT INTO Table1 (Month,Year) VALUES (''" & m & "'',''" & y & "'')"


Remember not to put quotes around any numeric values. This probably includes the year, and may or may not include the month.


Remember not to put quotes around any numeric values. This probably includes the year, and may or may not include the month.

When I run this it''s giving an error msg
Run time error :3709
the connection can not be used to perform this operation. it is closed or invalid in this context


Expand|Select|Wrap|Line Numbers


这篇关于更新年份和月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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