 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 21st, 2004, 06:50 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
SQL Server Error
I am getting the following error when adding an entry into tblDeals
Can someone see whats wrong..if had little luck fixing the error.
Microsoft OLE DB Provider for SQL Server error '80040e14'
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
/frmActivity-Add.asp, line 62
Code:
<%@LANGUAGE="VBSCRIPT"%>
<% HeaderType = "" %>
<% HeaderTitle = "Add Activity" %>
<%
dim strContact_ID
strContact_ID = Request("Contact_ID")
dim strDate2
strDate2 = Date() + 2
' *** Insert Record: construct a sql insert statement and execute it
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
If (CStr(Request("MM_insert")) <> "") Then
MM_tableName = "database.tblDeals"
MM_fields = "Contact_ID,Contact_ID,none,none,NULL,Position_ID,Position_ID,none,none,NULL,Associate_ID,Associate_ID,none,none,NULL,Deal_Status_ID,Deal_Status_ID,none,none,NULL,Deal_Type_ID,Deal_Type_ID,none,none,NULL,Notes,Notes,',none,'',Post_Date,Post_Date,',none,NULL,Last_Update,Last_Update,',none,NULL,Activity_Date,Activity_Date,',none,NULL"
MM_redirectPage = "frmContact-Detail.asp?Contact_ID=" & strContact_ID
' create the insert sql statement
MM_tableValues = ""
MM_dbValues = ""
MM_fieldsArray = Split(MM_fields, ",")
For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5
FormVal = CStr(Request.Form(MM_fieldsArray(i)))
Delim = MM_fieldsArray(i+2)
If (Delim = "none") Then Delim = ""
AltVal = MM_fieldsArray(i+3)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_fieldsArray(i+4)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fieldsArray)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_fieldsArray(i+1)
MM_dbValues = MM_dbValues & FormVal
Next
MM_insertStr = "insert into " & MM_tableName & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
' finish the sql and execute it
Set MM_insertCmd = Server.CreateObject("ADODB.Command")
MM_insertCmd.ActiveConnection = dbconn
MM_insertCmd.CommandText = MM_insertStr
MM_insertCmd.Execute
|
|

December 21st, 2004, 10:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Show us the actual SQL-string - you can get it by inserting two lines like this:
Code:
[...]
Next
MM_insertStr = "insert into " & MM_tableName & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
response.write MM_insertStr
response.end
' finish the sql and execute it
Set MM_insertCmd = Server.CreateObject("ADODB.Command")
[...]
|
|

December 22nd, 2004, 11:27 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
insert into database.tblDeals (Contact_ID,Position_ID,Associate_ID,Deal_Status_I D,Deal_Type_ID,Notes,Post_Date,Last_Update,Activit y_Date) values (38685,11856,53, 53,1,234,'','12/22/2004',NULL,'12/22/2004')
|
|

December 22nd, 2004, 11:36 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
this piece of code might be putting in the extra value
Code:
<td>
<select name='Associate_ID' style="font-size:8pt">
<option value="0"></option>
<%
While Not rsAssociates.EOF
%>
<option value="<%=(rsAssociates("Associate_ID"))%>" <%if (rsAssociates("Associate_ID") = Session("Username")) then Response.Write("SELECTED") : Response.Write("")%>><%=(rsAssociates("Initials"))%></option>
<%
rsAssociates.MoveNext()
Wend
rsAssociates.close()
set rsAssociates = nothing
%>
</select>*
</td>
|
|
 |