我用两个时间插件:DTPicker1 DTPicker2 和一个按钮Command1 。选择其中的一段时间删除,在按钮中执行下面代码但是不行 请帮我看看谢谢!如果能帮我加上一个进度条那更好了
Private Sub Command1_Click()
 If MsgBox("您真的要删除吗?", vbYesNo + 32, "信息删除") = vbYes Then ' 用户按下"是"
       Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=hao"
       strsql = "delete xx where 发送时间 >= " & "'" & DTPicker1.Value & "'and 发送时间 <= " & "'" & DTPicker2.Value & "'ORDER BY 发送时间"
       Adodc1.RecordSource = strsql
       Adodc1.Refresh          ' 完成某操作
    End If
End Sub

解决方案 »

  1.   

    语句不对
    strsql = "delete xx where 发送时间 >= #" & DTPicker1.Value & "# and 发送时间 <= #" & DTPicker2.Value & "# ORDER BY 发送时间"
           
    时间变量应用 # #,而不是用‘’
      

  2.   

    delete from xx另外:access数据库
     strsql = "delete from xx where 发送时间 >= #" & DTPicker1.Value & "# and 发送时间 <=#" & DTPicker2.Value & " # "sql server
     strsql = "delete from xx where 发送时间 >=CONVERT(DATETIME, '" & DTPicker1.Value  & "', 102) and 发送时间<=CONVERT(DATETIME, '" & DTPicker2.Value  & "', 102)"
      

  3.   

    Private Sub Command1_Click()
     If MsgBox("您真的要删除吗?", vbYesNo + 32, "信息删除") = vbYes then                   
              Adodc1.open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=hao"       
             call Adodc1.Execute ("delete xx where 发送时间 >= " & "'" & DTPicker1.Value & "'and 发送时间 <= " & "'" & DTPicker2.Value & "'ORDER BY 发送时间"
    )
           Adodc1.Refresh          ' 完成某操作
        End If
    End Sub
      

  4.   

    ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & DbFilePath & ";"strsql = "delete * from xx where 发送时间 >= #" & DTPicker1.Value & "# and 发送时间 <=#" & DTPicker2.Value & "#"为什么要用Adodc来执行一个SQL语句呢,直接用Connection对象的Execute方法执行不好吗?
      

  5.   

    select * from SKInformation a,ArkInfo b where a.id=b.id and  b.CheckInDate>='" & _
      DTStar.Value & "' and CheckInDate<='" & DTEnd.Value & "'"
    在ACCESS里不能運行?請問怎樣改呀?