使用经典asp插入数据不起作用 [英] Insert Data using classic asp is not working

查看:52
本文介绍了使用经典asp插入数据不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在数据库中插入 TextBox 值,但以下代码无效。我是经典ASP 的新手,我认为这将是数据库连接问题,直到所以它正在运行。任何人都可以告诉我解决方案。



I'm trying to insert the TextBox values in database, but the below code is not working. I'm new to Classic ASP, I thought that it would be the Database connection problem, up to so on it is working. could anybody tell me the solution.

ASP page




 <tr >
 <td class="fieldName" width="50%">Response Code</td>
 <td align="left" width="50%"><input id="txtrescode"  type="text"  runat="server"  readonly="readonly" value="<%=arrResp(0,1)%>"/></td>
 </tr>
		 
<tr >
<td class="fieldName" width="50%">Response Message</td>
<td align="left" width="50%"><input id="txtresmsg"  type="text"  runat="server" value="<%=arrResp(1,1)%>"/></td>
</tr>
		 
<tr >
<td class="fieldName" width="50%">Date Created</td>
<td align="left" width="50%"><input id="txtdatecreated"  type="text"  runat="server" value="<%=arrResp(2,1)%>"/></td>
</tr>
.
.
.
.
.
so on

<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="Provider=SQLOLEDB; Data Source=(local);Database=abc;User ID=sa;Password=abc"
objConn.Open
Dim SQL
SQL = "INSERT INTO responsedetails(ResponseCode, ResponseMesssage,..) values('"&txtrescode&"', '" &txtresmsg&"'...)"
objConn.Execute SQL		
objConn.Close
%>

推荐答案

你可以试试以下..



打印之前从文本框返回的值insert语句。类似下面的东西可以工作..



Respones.Write(Request.Form(txtrescode)); - POST方法







Respones.Write(Request.Querystring(txtrescode)); - 获取方法





如果它打印正确的值,那么只需硬编码一些值并测试插入是否正常工作。



在ASP(或任何其他应用程序)中,在打开连接之前,最好检查数据库连接是否处于关闭状态。否则关闭它然后调用open方法。

这将确保正确初始化连接对象。
Can you try the following..

Print the values returned from textbox before the insert statement. something like the below would work..

Respones.Write(Request.Form("txtrescode")); - POST Method

OR

Respones.Write(Request.Querystring("txtrescode")); - GET Method


If it prints correct values, then just hard code some values and test whether insert is working fine.

In ASP (or any other application), before opening a connection, it is better to check whether DB connection is in closed state. otherwise close it and then call open method.
This will ensure that connection objects are initialised properly.


这篇关于使用经典asp插入数据不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆