标题:[求助]写网页的时候遇到SQL语句的问题!
只看楼主
gov
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-11-8
 问题点数:0 回复次数:1 
[求助]写网页的时候遇到SQL语句的问题!

网页中报的错误:

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]列名 '主题' 无效。

/guest.asp,行 115

界面:


数据库的设计图:

代码如下:(红色加粗的代码是出错行)
<!--#include file="inc/conn.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = connstr
MM_editTable = "guest"
MM_editRedirectUrl = "guestok.asp"
MM_fieldsStr = "zhuti|value|select|value|xin|value|mail|value|laizi|value|dizhi|value|tel|value|xinxi|value"
MM_columnsStr = "主题|',none,''|类型|',none,''|姓名|',none,''|邮件|',none,''|来自|',none,''|地址|',none,''|电话|',none,''|信息|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim R6
Dim R6_numRows

Set R6 = Server.CreateObject("ADODB.Recordset")
R6.ActiveConnection = connstr
R6.Source = "SELECT * FROM guest_lei ORDER BY G_ID ASC"
R6.CursorType = 0
R6.CursorLocation = 2
R6.LockType = 1
R6.Open()

R6_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>liuyan</title>
<link href="css/asa.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--


function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.07
//copyright (c)1998,2001 Yaromat.com
var args = YY_checkform.arguments,myDot=true,myV='',myErr='',addErr=false,myReq,rx,myObj1,myMa,myAt;
for (var i=1; i<args.length;i=i+4){
if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));myV=myObj.value;
if (myObj.type=='text'||myObj.type=='password'){
if (myReq&&myObj.value.length==0)addErr=true;
if ((myV.length>0)&&(args[i+2]==1)){ //fromto
if (!(myV/1)||myV<args[i+1].split('_')[0]/1||myV > args[i+1].split('_')[1]/1){addErr=true}
}
if ((myV.length>0)&&(args[i+2]==2)){ // email
rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
}
if ((myV.length>0)&&(args[i+2]==3)){ // date
myMa=args[i+1].split("#");myAt=myV.match(myMa[0]);
if(myAt){
var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
var myDate=new Date(myY,myM,myD);
if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
}else{addErr=true}
}
if ((myV.length>0)&&(args[i+2]==4)){myMa=args[i+1].split("#");myAt=myV.match(myMa[0]);if(!myAt)addErr=true}// time
if (myV.length>0&&args[i+2]==5){ // check this 2
var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
if(!myObj1.checked)addErr=true;
}
if (myV.length>0&&args[i+2]==6){myObj1=MM_findObj(args[i+1]);if(myV!=myObj1.value)addErr=true;}// the same
}else
if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
if (args[i+2]==2){
var myDot=false;
for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
if(!myDot){myErr+='' +args[i+3]+'\n'}
}
}else
if (myObj.type=='checkbox'){
if(args[i+2]==1&&myObj.checked==false){addErr=true}
if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
}else
if (myObj.type=='select-one'||myObj.type=='select-multiple'){
if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
}else
if (myObj.type=='textarea'){
if(myV.length<args[i+1]){addErr=true}
}
if (addErr){myErr+=''+args[i+3]+'\n'; addErr=false}
}
if (myErr!=''){alert('\t\t\t\t\t\n\n'+myErr)}
document.MM_returnValue = (myErr=='');
}
//-->
</script>
</head>

<body background="images/bg_v3.gif">
<SCRIPT language=JavaScript1.2 src="mouse.js"></SCRIPT>
<table width="778" height="607" border="0" align="center" cellpadding="8" cellspacing="0">
<tr>
<td height="607" valign="top" bgcolor="#FFFFFF"><map name="Map5">
<area shape="rect" coords="92,11,143,24" href="/default.asp">
<area shape="rect" coords="90,55,142,68" href="/tupian/index.asp">
<area shape="rect" coords="92,34,143,47" href="/news.asp">
<area shape="rect" coords="92,79,142,92" href="/job.asp">
<area shape="rect" coords="91,102,144,115" href="/guest.asp">
<area shape="rect" coords="92,124,143,138" href="/host.asp">
<area shape="rect" coords="94,148,143,161" href="/about.asp">
<area shape="rect" coords="93,172,142,185" href="/bbs/default.asp" target="_blank">
</map>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="8"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24">&nbsp;</td>
</tr>
<tr>
<td height="357" valign="top" bgcolor="#e9e7e3"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="98%" height="298" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<form action="<%=MM_editAction%>" method="POST" name="form1" onSubmit="YY_checkform('form1','zhuti','#q','0','主题必须填写','xin','#q','0','姓名必填项','mail','#','2','必填项请填写正确的邮箱地址');return document.MM_returnValue">
<table width="67%" height="190" border="0" align="center" cellpadding="0" cellspacing="1" class="01">
<tr>
<td width="16%" height="20">留言主题:</td>
<td width="84%">
<input name="zhuti" type="text" class="biaodan" id="zhuti" size="50">
<font color="#990000">*必填项目</font></td>
</tr>
<tr>
<td height="20">留言类型:</td>
<td> <select name="select" size="1" class="biaodan">
<option value="请选择" selected <%If (Not isNull((R6.Fields.Item("leibie").Value))) Then If ("请选择" = CStr((R6.Fields.Item("leibie").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>请选择</option>
<%
While (NOT R6.EOF)
%>
<option value="<%=(R6.Fields.Item("leibie").Value)%>" <%If (Not isNull((R6.Fields.Item("leibie").Value))) Then If (CStr(R6.Fields.Item("leibie").Value) = CStr((R6.Fields.Item("leibie").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(R6.Fields.Item("leibie").Value)%></option>
<%
R6.MoveNext()
Wend
If (R6.CursorType > 0) Then
R6.MoveFirst
Else
R6.Requery
End If
%>
</select></td>
</tr>
<tr>
<td height="20">姓名:</td>
<td>
<input name="xin" type="text" class="biaodan" id="xin" size="30">
<font color="#990000">*真实的姓名</font></td>
</tr>
<tr>
<td height="20">E-mail:</td>
<td>
<input name="mail" type="text" class="biaodan" id="mail" size="30">
<font color="#990000">*填写正确的邮箱地址以便我们联系您</font></td>
</tr>
<tr>
<td height="20">来自:</td>
<td>
<input name="laizi" type="text" class="biaodan" id="laizi" size="30"></td>
</tr>
<tr>
<td height="20">地址:</td>
<td>
<input name="dizhi" type="text" class="biaodan" id="dizhi" size="50"></td>
</tr>
<tr>
<td height="20">电话:</td>
<td>
<input name="tel" type="text" class="biaodan" id="tel" size="30"></td>
</tr>
<tr>
<td height="20">留言信息:</td>
<td><font color="#990000">请适当使用Enter键换行输入</font></td>
</tr>
<tr>
<td height="20">&nbsp;</td>
<td>
<textarea name="xinxi" cols="70" rows="10" class="biaodan" id="xinxi"></textarea></td>
</tr>
</table>
<table width="18%" height="23" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td>
<div align="center">
<input name="Submit" type="submit" class="biaodan" value="提交留言">
</div></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1">
</form></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="8"></td>
</tr>
</table>
<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%" height="40"><img src="images/tai_17.gif" width="155" height="40"></td>
<td width="54%" class="01"> 扬名设计——广州扬名设计中心 | 版权所有 严禁复制 <br>
 Copyright&copy;2005 <font color="#990000">扬名设计</font> All Rights
Reservies </td>
<td width="26%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="23%"><bgsound src=beij.mid loop="-1"></td>
<td width="77%" class="01"><strong><font color="#660000">粤ICP备05076342号</font></strong></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<%
R6.Close()
Set R6 = Nothing
%>




[此贴子已经被islet于2006-11-8 16:33:49编辑过]



aB50qMh7.jpg (32.91 KB)


txO5i2mK.jpg (43.61 KB)
搜索更多相关主题的帖子: SQL 网页 语句 
2006-11-08 14:34
tang688
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1219
专家分:35
注 册:2004-12-25
得分:0 
加一段程序,把这个值先显示出来看看:MM_editQuery

2006-11-09 09:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-101497-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050540 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved