none
Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005' RRS feed

  • 问题

  • 本人开发一个登陆网页,但搞了半天,还是个鬼样:

    Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'

    [Microsoft][ODBC Driver 17 for SQL Server]默认参数的使用无效

    /Default.asp,行 29

    网页代码:

      

    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/conn.asp" -->
    <%
    ' *** Validate request to log in to this site.
    MM_LoginAction = Request.ServerVariables("URL")
    If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
    MM_valUsername = CStr(Request.Form("user-name"))
    If MM_valUsername <> "" Then
      Dim MM_fldUserAuthorization
      Dim MM_redirectLoginSuccess
      Dim MM_redirectLoginFailed
      Dim MM_loginSQL
      Dim MM_rsUser
      Dim MM_rsUser_cmd

      MM_fldUserAuthorization = ""
      MM_redirectLoginSuccess = "map.html"
      MM_redirectLoginFailed = "Default.asp"

      MM_loginSQL = "SELECT name, password"
      If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
      MM_loginSQL = MM_loginSQL & " FROM dbo.[User information] WHERE name = ? AND password = ?"
      Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
      MM_rsUser_cmd.ActiveConnection = MM_conn_STRING
      MM_rsUser_cmd.CommandText = MM_loginSQL
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 255, MM_valUsername) ' adVarChar
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 255, Request.Form("password")) ' adVarChar
      MM_rsUser_cmd.Prepared = true
      Set MM_rsUser = MM_rsUser_cmd.Execute

      If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
        ' username and password match - this is a valid user
        Session("MM_Username") = MM_valUsername
        If (MM_fldUserAuthorization <> "") Then
          Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
        Else
          Session("MM_UserAuthorization") = ""
        End If
        if CStr(Request.QueryString("accessdenied")) <> "" And false Then
          MM_redirectLoginSuccess = Request.QueryString("accessdenied")
        End If
        MM_rsUser.Close
        Response.Redirect(MM_redirectLoginSuccess)
      End If
      MM_rsUser.Close
      Response.Redirect(MM_redirectLoginFailed)
    End If
    %>
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登陆-蓝服一号</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link href="/css/Div.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <header class="header">登录</header>
    <hr class="hr">
    <address>
    <div id="Div">
    <form ACTION="<%=MM_LoginAction%>" METHOD="POST">
    <p>
    <input type="text" name="user-name" id="user-name" class="form-control" placeholder="姓名">
    </p>
    <p>
    <input type="password" name="password" id="password" class="form-control" placeholder="密码">
    </p>
    <p>
    <button class="btn btn-lg btn-primary btn-block">登录</button>
    </p>
    </form>
    <p>
    <button class="btn btn-lg btn-dark btn-block">忘记密码</button>
    </p>
    </div>
    </address>
    <footer class="footer"> ©2018 Blue Studio.All rights reserved. </footer>
    <script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> 
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> 
    <script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    </body>
    </html>

    数据库配置连接代码:

    <%
    ' FileName="Connection_odbc_conn_dsn.htm"
    ' Type="ADO" 
    ' DesigntimeType="ADO"
    ' HTTP="false"
    ' Catalog=""
    ' Schema=""
    Dim MM_conn_STRING
    MM_conn_STRING = "dsn=conn;uid=sa;pwd=13724440988AAA;"
    %>

    求大神们救救我!此问题纠结了很久了!!!

    2018年7月19日 12:44

全部回复

  • conn_STRING = "dsn=conn;uid=sa;pwd=13724440988AAA;"

    这个有错误,参考这里

    https://www.connectionstrings.com/microsoft-ole-db-provider-for-sql-server-sqloledb/

    Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;
    User Id
    =myUsername;Password=myPassword;


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2018年7月20日 0:26
  • 还是有错误:

    Microsoft OLE DB Provider for SQL Server 错误 '80040e14'

    参数化查询 '(@P1 varchar(255),@P2 varchar(255))SELECT name, password FROM db' 需要参数 '@P2',但未提供该参数。

    /Default.asp,行 29

    数据库配置连接代码:

    <%
    ' FileName="Connection_ado_conn_string.htm"
    ' Type="ADO" 
    ' DesigntimeType="ADO"
    ' HTTP="false"
    ' Catalog=""
    ' Schema=""
    Dim MM_conn_STRING
    MM_conn_STRING = "Provider=sqloledb;Data Source=192.168.0.105;Initial Catalog=conn;User Id=sa;Password=13724440988AAA;"
    %>

    2018年7月23日 13:28
  • SQL语句有错误

    "@P1 varchar(255),@P2 varchar(255))SELECT name, password FROM db"

    @P2参数没有传值进去。


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2018年7月24日 0:24
  • 咋弄?麻烦把应该更改的代码给我

    小弟刚刚学ASP,望大师多多指导!

    2018年7月27日 13:39