| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 809 人关注过本帖
标题:System.Data.OleDb.OleDbException: 查询值的数目与目标字段中的数目不同。
取消只看楼主 加入收藏
davidzhengxy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-24
收藏
 问题点数:0 回复次数:0 
System.Data.OleDb.OleDbException: 查询值的数目与目标字段中的数目不同。

insert.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insertdata.asp</title>
</head>

<body>
<h3>Insert data</h3>
<form action="insert1.aspx" method="post" name="insert1">
<ul>
<li>ID:<input type="Integer" name="ID" size="10">
<li>Pagecontent:<input type="text" name="Pagecontent" size="50">
<li>Contact:<input type="text" name="Contact" size="10">
<li>Type0:<input type="text" name="Type0" size="10">
<li>Group:<input type="text" name="Group" size="10">
<li>June:<input type="text" name="June" size="10">
<li>July1:<input type="text" name="July1" size="10">
<li>July:<input type="text" name="July" size="10">


<li>FaxOREmail:<input type="text" name="FaxorEmail" size="10">
<li>Type1:<input type="text" name="Type1" size="10">
<li>Photo:<input type="text" name="Photo" size="10">
<li>Send:<input type="text" name="Send" size="10">
<li>Proof:<input type="text" name="Proof" size="10">
<li>PDF:<input type="text" name="PDF" size="10">
<li>Fax:<input type="text" name="Fax" size="10">
<li>Cell:<input type="text" name="Cell" size="10">
</ul><br>
<input type="submit" value="insert" name="b1">
<input type="reset" value="eliminate" name="eliminate">
</form>
</body>
</html>
insert1.aspx
Import NameSpace="System.Data"%>
<%@ Import NameSpace="System.Data.OleDb"%>
<%@ Page Debug="true" %>
<script language="VB" runat="Server">

Dim objConn As OleDbConnection
Dim strSQL As String
Function Get_DSN(bolSQL As Boolean) As String
If Not bolSQL Then
Get_DSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("/Realty.mdb")
Else
Get_DSN="Provider=SQLOLEDB.1;Data Source=Alvinnt;User ID=sa;"&"Password=;Initial Catalog=ASPNEW;autotranslate=no;"
End If
End Function

'Function Check_No(bno As String) As Boolean
' Dim objDR As OleDbDataReader
' Dim objCmd As OleDbCommand
'strSQL="select* from June where ID='" & id & "'"
'objCmd=New OleDbCommand(strSQL,objConn)
'objCmd.Connection.Open()
'objDR=objCmd.ExecuteReader()
'Check_No=False
' While objDR.Read()
' Check_No=True
' End While
'End Function


Sub Page_Load(Sender As Object, E As EventArgs)
Dim objCmd As OleDbCommand
Dim strSQL,strDSN As String
Dim ID As String
Dim Pagecontent As String
Dim Contact,Type0,Group,June,July1,July,FaxorEmail,Type1,Photo,Send,Proof,PDF,Fax,Cell As String

'ID=Request.Form("ID")
Pagecontent=Request.Form("Pagecontent")
Contact=Request.Form("Contact")

Type0=Request.Form("Type0")
Group=Request.Form("Group")
June=Request.Form("June")
July1=Request.Form("July1")
July=Request.Form("July")
FaxorEmail=Request.Form("FaxorEmail")
Type1=Request.Form("Type1")
Photo=Request.Form("Photo")
Send=Request.Form("Send")
Proof=Request.Form("Proof")
PDF=Request.Form("PDF")
Fax=Request.Form("Fax")
Cell=Request.Form("Cell")

strDSN=Get_DSN(False)
objConn=New OleDbConnection(strDSN)


'If Not Check_No(id) Then 'not exist
'definite "insert"

strSQL="insert into June values('"& ID &"','"& Group &"','"& June &"','"& July1 &"','"& July &"','"& FaxorEmail &"','"& Type1 &"','"& Photo &"','"& Send &"','"& Proof &"','"& PDF &"','"& Fax &"','"& Cell &"')"
objConn=New OleDbConnection(strDSN)

objCmd=New OleDbCommand(strSQL, objConn)
objCmd.connection.Open()
objCmd.ExecuteNonQuery()
objCmd.Connection.Close()
Response.Write (strSQL)
Response.Write ("<h3>Insert data successfully!</h3>")
Response.Write ("<ul>")
Response.Write ("<li>ID: <font color='blue'>"& id &"</font>")
Response.Write ("<li>Pagecontent: <font color='blue'>"& pagecontent &"</font>")
Response.Write ("<li>Contact: <font color='blue'>"& contact &"</font>")
Response.Write ("<li>Group: <font color='blue'>"& Group &"</font>")
Response.Write("</ul>")
'Else
'Show_Msg("this ("& id &") is exist,plese enter again")
'End If
End Sub

'Sub Show_Msg(strMsg As String)
'Response.Write("<h2><font color='red'>")
'Response.Write(strMsg & "</font></h2>")
' Response.Write("<hr><a href='javasript.go(-1)'>")
'Response.Write("back to previous page!</a>")
'End Sub

</script>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
</body>
</html>

搜索更多相关主题的帖子: Data 字段 目标 System OleDb 
2006-06-30 15:48
快速回复:System.Data.OleDb.OleDbException: 查询值的数目与目标字段中的数目不 ...
数据加载中...
 
   



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

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