| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 186 人关注过本帖
标题:插入不重復的資料
收藏  订阅  推荐  打印 
jxyga111
Rank: 12Rank: 12Rank: 12
来自:中華人民共和國
等级:版主
威望:11
帖子:4190
积分:5020
注册:2008-3-21
插入不重復的資料

Dim x As String
Dim date11 As Date
Dim cn As New Connection
Dim objrs2 As New Recordset

    x = Format(DTP1.Value, "yyyymmdd") & "至" & Format(DTP2.Value, "yyyymmdd")
    date11 = DTP1.Value
   
    cn.Execute "DELETE from t_a where td013 between'" & Format(DTP1.Value, "yyyymmdd") & "' And '" & Format(DTP2.Value, "yyyymmdd") & "'"
   
    For a = 0 To weeks - 1
        tempdate = DateAdd("ww", a, date1) + 6
        k = "insert into t_a select tda=" & a + 1 & ",date1='" & x & "',TD008,SUM(TD008),bhd=0,maxqty=0,remark='',td013=TD013 from COPTD where  TD013 between '" & Format(DTP1.Value, "yyyymmdd") & "' AND '" & Format(DTP2.Value, "yyyymmdd") & "'group by TD008,TD013"
        cn.Execute k
    Next
    For q = 0 To a
        Set objrs2 = Nothing
        objrs2.CursorLocation = adUseClient
        If a = q Then
            Set objrs = Nothing
            objrs2.Open "select distinct tda,date1,count(td0081),td008,bhd=sum(td008)/625,maxqty,remark,td013 from t_a    where td013 BETWEEN '" & Format(DTP1.Value, "yyyymmdd") & "'  and  '" & Format(DTP2.Value, "yyyymmdd") & "'  group by tda,date1,td008,maxqty,remark,td013", cn, 3, 2
        End If
    Next
由於要將第幾周寫入進去,望高手調試,指教一下
2008-8-9 08:58
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.048618 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved