我用ADO连接ACCESS数据库执行以下语句不会错:
Adodc3.RecordSource = "select username,gatetime ,status from  InOut where datediff('d','" & timenow & "',GateTime)=0  and inout inout='签到'"可我再用ADO连接SQL数据库执行上面语句时却出现:”“为DATEDIFF 指定了无数的参数1“
请问这是怎么一回事呢?????

解决方案 »

  1.   

    where  是列名 你后面加那么多参数 干什么?
      

  2.   

    数据库引擎不支持 datediff 函数。改 SQL 语句吧。
      

  3.   

    Adodc3.RecordSource = "select username,gatetime ,status from  InOut where datediff('d','" & timenow & "',GateTime)=0  and inout inout='签到'" 是否多了一个 inout,或丢掉了两个 inout 之间的圆点 . ?另,试试:
    Adodc3.RecordSource = "select username,gatetime ,status from  InOut where GateTime >= '" & format(date, "yyyy-mm-dd) & "' and GateTime < '" & format(date + 1, "yyyy-mm-dd) & " and inout='签到'"
      

  4.   

    Adodc3.RecordSource = "select username,gatetime ,status from  InOut where datediff(day,'" & timenow & "',GateTime)=0  and inout='签到'"SQL 中的datediff函数和VB中的不太一样,第一个参数不用字符串
      

  5.   

    Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long不必锁定。你可以在系统启动时保存 GetTickCount 的值和日期时间值,退出时再取。GetTickCount 是系统运行以来的毫秒数,可表示数十天的长度。求出 GetTickCount 之差/1000,和 datediff("s", begintime, endtime)。如果相差较多,就是改了。可以根据你的记录恢复日期时间值。
      

  6.   

    Private Sub Command5_Click()
    Dim hregkey As Long  ' receives handle to the newly created or opened registry key
    Dim secattr As SECURITY_ATTRIBUTES  ' security settings of the key
    Dim subkey As String  ' name of the subkey to create
    Dim neworused As Long  ' receives 1 if new key was created or 2 if an existing key was opened
    Dim stringbuffer As Long   ' the string to put into the registry
    Dim retval As Long  ' return value'' Set the name of the new key and the default security settings
    subkey = "Software\Microsoft\windows\CurrentVersion\policies\Explorer"
    secattr.nLength = Len(secattr)  ' size of the structure
    secattr.lpSecurityDescriptor = 0  ' default security level
    secattr.bInheritHandle = True  ' the default value for this setting
    '
    '' Create or open the registry key
    retval = RegCreateKeyEx(hkey_local_machine, subkey, 0, "", 0, KEY_WRITE, secattr, hregkey, neworused)
    'If retval <> 0 Then  ' error during open
    '  Debug.Print "Error opening or creating registry key -- aborting."
    '  End  ' terminate the program
    'End If' Write the string to the registry.  Note that because Visual Basic is being used, the string passed to the
    ' function must explicitly be passed ByVal.
    stringbuffer = 1         ' note how a null character must be appended to the string
    retval = RegSetValueEx(hregkey, "norun", 0, REG_DWORD, stringbuffer, Len(stringbuffer))  ' write the stringEnd Sub
    请问这些代码是否是禁止某项功能的实现如果用这些代码是否能实现时间的锁定
    能帮我修改吗???
    拜托!!!!