×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

web page 高手帮我看看,我的code 有什么问题,多多谢了。

IE 显示如下信息:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 3。 /myweb/mgpr.asp, line 19
另外,我对INSERT INTO 的语法不太清楚。
非常感谢您的帮助。

<%
'get the form variables
productid=TRIM (Request ("product id"))
productname=TRIM (Request ("product name"))
productnumber=TRIM (Request ("product number"))

'open database connection
Set Con=Server.CreateObject("ADODB.Connection")
Con.Open "molDSN"
%>

<html>
<body>
<%
'add new product
if productname<> "" then
sqlString=" INSERT INTO module1 (product_id,product_name, product_number)" &_
" VALUES( productid,productname,prouctnumber) "
Con.Execute sqlString
%>
<table>
<tr><td><%=productname%> was added to the database</td></tr></table>
<%
end if
%>
<a href="addpr.asp">Add product</a>

</body>

</html>
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / web page 高手帮我看看,我的code 有什么问题,多多谢了。
    IE 显示如下信息:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
    [Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 3。 /myweb/mgpr.asp, line 19
    另外,我对INSERT INTO 的语法不太清楚。
    非常感谢您的帮助。

    <%
    'get the form variables
    productid=TRIM (Request ("product id"))
    productname=TRIM (Request ("product name"))
    productnumber=TRIM (Request ("product number"))

    'open database connection
    Set Con=Server.CreateObject("ADODB.Connection")
    Con.Open "molDSN"
    %>

    <html>
    <body>
    <%
    'add new product
    if productname<> "" then
    sqlString=" INSERT INTO module1 (product_id,product_name, product_number)" &_
    " VALUES( productid,productname,prouctnumber) "
    Con.Execute sqlString
    %>
    <table>
    <tr><td><%=productname%> was added to the database</td></tr></table>
    <%
    end if
    %>
    <a href="addpr.asp">Add product</a>

    </body>

    </html>
    • I don't think you can use connection to execute statement, can you?
      • Exactly, So what;s the problem? Thanks a lot.
    • An error:
      sqlString=" INSERT INTO module1 (product_id,product_name, product_number)" &_
      " VALUES( productid,productname,prouctnumber) "


      This sentense is definately wrong. You put productid, productname, productnumber inside the quot....
      • Thanks, So how to change it. As i said, I am not familiar with this Command, and especially about the useage of quotation marks.Could you please show me how to correct it ?Thanks a lot.
        • Sorry. I program with JScript. I can't write out VBScript with correct syntax without testing it. But you can look at my JScript exampe for inserting.
          本文发表在 rolia.net 枫下论坛Application("connStr") = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=e:\\MP3DB.mdb"

          var logIP = "INSERT INTO IPLOG VALUES ('" + Session("IP") + "', 1, #" + get_MMDDYYYY_datetime() + "#)"

          Session("IP") = String(Request.ServerVariables("REMOTE_ADDR"))

          var log = Server.CreateObject("ADODB.Command");
          log.ActiveConnection = Application("connStr");
          log.CommandText = logIP;
          log.Execute();

          function get_MMDD_date(dat) {
          var month = "0" + (dat.getMonth() + 1)
          month = month.substr(month.length-2)
          var day = "0" + dat.getDate()
          day = day.substr(day.length-2)
          return (month + day)
          }

          function get_MMDDYYYY_datetime(){
          var Today = new Date()
          return get_MMDDYYYY_date(Today) + " " + get_HHMMSSTT_time(Today)
          }


          function get_HHMMSSTT_time(dat) {
          var vMinutes = "0" + dat.getMinutes()
          vMinutes = vMinutes.substr(vMinutes.length-2)
          var vSeconds = "0" + dat.getSeconds()
          vSeconds = vSeconds.substr(vSeconds.length-2)
          var vHours = dat.getHours()
          if (vHours > 11) {
          vHours = vHours - 12
          vHours==0?vHours=12:vHours=vHours
          return (vHours + ":" + vMinutes + ":" + vSeconds + " PM")
          }
          else {
          vHours==0?vHours=12:vHours=vHours
          return (vHours + ":" + vMinutes + ":" + vSeconds + " AM")
          }
          }更多精彩文章及讨论,请光临枫下论坛 rolia.net
          • Thanks a lot, my friend.
    • 好象是
      字符型的VALUE要用单引号,另外如果其中一个值没有PASS过来也会出错,最简单的办法show一下你的sql,马上可以发现错误
      • Thanks. But what you mean showing my SQL? I use ACCESS
        I use ACCESS to bulid a database table.I don't know how to show it. I am sure the problem occurs in INSERT INTO syntax, but I can't figure out what error occurs. Maybe that 's what we called " blind point". tHANK YOU AGIAN.
        • try
          sqlString=" INSERT INTO module1 (product_id,product_name, product_number)" &_
          " VALUES( productid,productname,prouctnumber) "
          '---------------------------------------------------------------------
          respose.write sqlString '<------------here
          '---------------------------------------------------------------------
          Con.Execute sqlString
    • SQL statment error, the right should be : sqlString=" INSERT INTO module1 (product_id,product_name, product_number)" &_ " VALUES( ' "& productid &" ', ' " &productname &" ', ' " & prouctnumber & " ' ) "
      if your productid is number, you needn't ' for that one.

      one suggestion:
      you write: TRIM (Request ("product name"))
      in Form, don't use space for the name of item, use _ is better
    • my answer...
      the database connection should be
      dim Con
      Set Con=Server.CreateObject("ADODB.Connection")
      objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
      objConn.Open "path\database.mdb"

      or

      dim Con, strC
      Set Con = Server.CreateObject("ADODB.Connection")
      strC = "Data Source = datasourcename;User ID=userid;Password=password;"
      objConn.Open strC


      the insert sql statement should be
      sqlString= "INSERT INTO module1 (product_id,product_name, product_number)VALUES("'" & productid & "','" & productname & "','" & prouctnumber & "')"

      read some online document for vbscript before your began to program.
      • waokool是在ODBC里设置了数据源. 我也喜欢用ODBC, 在CODE里不用写一大堆的东西. 从他的错误来看,数据库已经连上了,只是没有参数传上去. 但是waokool 你要注意, 用ACCESS数据库, 不要把MDB文件放在WEB FOLDER里面,
        不然会给人DOWNLOAD下来的. 你用ODBC, 你想放哪里都可以.
        • Thank you all.Reply for all friends. the code still doesn't work.IE show some information.
          Hi, my friends. I agree with the INSERT INTO syntax suggested by xiaodongxi and Gamma, I can find a similar example on book, But it looks sth. wrong wrong with "Con.Execute sqlString". After I modified the INSERT INTO , the IE show "
          Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
          [Microsoft][ODBC Microsoft Access 驱动程序] 标准表达式中数据类型不匹配。
          /myweb/mgpr.asp, line 20 "
          The line 20 is "Con.Execute sqlString"
          So what's the problem. Give me a hand. Thank you all.
          • For example, if you are passing string into a field that's defined as type "number". Then you will get that error.
            • Nice to see you again. I've checked the database table. Nothing wrong with data type.As for your second suggestion, to be honest, I am not clear. I am just beginner.
        • If you don't use ODBC, you can put it anywhere as well... Use ODBC is slower, by the way. OLEDB connection is the fastest.