日期:2014-05-17  浏览次数:20685 次

刚学asp,小问题,送分,谢谢!
将文本框的值,写入数据库,如何做?
<SCRIPT   LANGUAGE= "VBScript "   Runat= "Server ">  
Sub   cmdChangeIt_onClick
dim   connstr,conn,record,sql
connstr= "Driver={SQL   Server};Server=.;Uid=sa;pwd=sa;Database=Lpos5_B_dingguagua; "
Set   conn   =   Server.Createobject( "ADODB.Connection ")  
conn.CommandTimeout   =   2000
conn.open   connstr

Set   Record1=Server.CreateObject( "Adodb.Recordset ")
sql= "insert   into   w_b_fqs_m   (billnum,midornigth,LastUpdateTime)   values   ( ' "&   str   & " ', "&   txt.value   & ",getdate()) "       '不能引用文本框的值
Record1.Open   sql,conn

End   Sub

If   Request.ServerVariables( "REQUEST_METHOD ")   =   "POST "   Then
        If   Request.Form( "cmdChangeIt ")   =   "ent "   Then
              Call   cmdChangeIt_onClick
             
               
        End   If
End   If

</SCRIPT>  
<HTML>
<HEAD> <TITLE> </TITLE>
</HEAD>
<BODY>
<HR>
<FORM     id= "MyForm "   name= "MyForm "   method= "post "   action= "test.asp ">
<INPUT   TYPE= "submit "   NAME= "cmdChangeIt "   VALUE= "ent "   />
<input   name= "txt "   type= "text "   id= "txt "     />


</FORM>
</BODY>
</HTML>

------解决方案--------------------
......
服务端和客户端概念 混淆的厉害
建议先搞清楚这2个的差别
------解决方案--------------------
document.txt.value
------解决方案--------------------
两年没玩ASP,不对别见怪。

先熟悉引号的转义,印象中记得,两双变一双,两单变一单。

要说字串“3” 那么 x = "3 ",
要说字串“456” 那么 x = "456 ",
要说字串“ '” 那么 x = " ' ' " ,或 x = " " ' " ,ASP中两个引号在一起,只看后面一个
要说字串“ "” 那么 x = " " " " ,或 x = " ' " " ,ASP中两个引号在一起,只看后面一个
要说字串“fs+ "4fs "” 那么 x = "fs+ " "4fs " " " ,或 什么自己试 ,
要说字串“ ' ' " " " ' ' ' ' " " " " " ' ' " "” 那么 x = "....... " ,.......不好意思,电脑出错了。
------解决方案--------------------
<FORM id= "MyForm " name= "MyForm " method= "post " action= "test.asp ">
//表单提交到test.asp是吧!!你有那个页面吗??
//如果就是本页,那么你还要在服务器端获取表单传过去的值request( "value ");
//表单的输出填写是在客户端执行,而写入数据库更新数据是在提交后的服务器端执行
楼主补课吧!!嘿嘿~~~~~~~~