writing to database using .asp
Hi I am trying to write values to a database, but when using the INSERT
keyword, i get this error : Number of query values and destination fields
are not the same. I have reduced my number of query values and destination
fields to just one so they are definitely the same. Anyone got any ideas? the code is as follows:
<%
If Len(Request.Form("Company")) = 0 Then
Response.Redirect("addError.asp")
Else
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=AppsDB"
Company = ReplaceQuotes(Request.Form("Company"))
' Division = ReplaceQuotes(Request.Form("Division"))
' Device = ReplaceQuotes(Request.Form("Device"))
' Engineer = ReplaceQuotes(Request.Form("Engineer"))
' MainIssue = ReplaceQuotes(Request.Form("MainIssue"))
' DateReceived = ReplaceQuotes(Request.Form("DateReceived"))
strSql = "INSERT INTO MainTable VALUES('" & Company & "')"
', '" & Division & "', '" & Device & "', '" & Engineer & "', '" & MainIssue & "', '" & DateReceived & "')"
Conn.Execute(strSql)
Conn.Close
Set Conn = Nothing
End If
Function ReplaceQuotes(strValue)
strValue = Replace(strValue, "'", "''")
ReplaceQuotes = strValue
End Function
%>
|