November 19th, 2015, 12:00 PM
asp.net page not updating SQL table
I have been given the task of migrating an aspx-based web page used to generate sales quotes to a new server, made more difficult by the fact my coding knowledge is very limited. I am trying to migrate it from a Windows 2003 server with IIS 6.0 to a Windows 2008 server with IIS 7.5. The existing version connects to a SQL 2005 database, housed on the same server as the site (the new server has SQL 2008). When authorized users connect to the site (via AuthentiX), they are asked to select an item to quote from a list and add it to the quote. A popup appears to select options (the user just enters a quantity next to each option desired), which they are then asked to add to the quote. The next page allows them to add taxes, fees, and shipping or other miscellaneous charges. The users are then prompted to enter the sales person's name, email, and mailing address, plus the same information for the customer. The final page allows the user to review the quote, then submit it or go back and change it. When the user submits the quote, five things happen:
- A scrolling progress bar appears.
- The quote information is entered into one of three tables the SQL database (for general information, what item was quoted, and what options). There is a separate SQL user for the quote site which is set as the DB owner.
- A PDF file for the quote is generated and stored on the server, and the name of the file is stored in the 1st SQL table mentioned above (quotes).
- Emails are generated and sent to the salesman and customer whose email addresses were entered in the quote, plus our inside sales rep (their email address is stored in the site code).
- The progress bar is replaced by a confirmation screen, whereby the user can view the PDF file or go back to the initial quote screen.
Here is the portion of the site code where this is supposed to happen:
As of now, the progress bar disappears and I end up back at the quote review screen. In addition, the emails are never sent (the sales rep and I don't see them because I've used my personal and work emails in testing). Finally, clicking on the "View PDF" button initially resulted in a HTTP 403 error. I could also click on a "Quote History" button to review that user's past quotes (where they can view, edit, or delete their quotes), and that View PDF button also doesn't work for new quotes. However, I can view PDFs of past quotes. When I looked at the database through MS Access, I found the field where the file name of the PDF is supposed to be is blank on the new test quotes. I know the PDF exists because I can go the the file folder where the PDFs are stored and see it. Email should be working because I have and SMTP virtual server set up in IIS and it is authorized to connect to our Exchange server. After researching the matter of the PDFs, I suspected a permissions issue. One solution suggested enabling Directory Browsing, which I did. I can now view the PDFs for my test quotes, but only because I am now presented with the list of all of the quotes ever generated on the site (not the desired solution).I've tried modifying to code so that it would return whatever results are being generated, so I could see what the problem is. However, no results are returned.
Dim fname, fpath As String
fname = "Quote" & quoteid.ToString & "_ " & DateTime.Now.Ticks.ToString.Substring(2, 10) & ".pdf"
fpath = ConfigurationManager.AppSettings("pdf_folder") & "\" & fname
general.sendMail(TBcustemail.Text, "", "Quote #" & quoteid.ToString & " for Equipment", replace_break(TBemalcontent.Text), ConfigurationManager.AppSettings("from_email"), fpath, TBdealeremail.Text)
Lfinalmsg.Text = "Quote #" & quoteid.ToString & " was saved & delivered succesfully!<br ><a href=""quotes_pdf/" & fname & """ target=""_blank"">click here to view the quote pdf</a>"
ssql = "UPDATE quotes SET pdfname='" & fname & "' WHERE quote_id=" & quoteid.ToString
cmd.CommandText = ssql
So the question is, how can I get the emails the send (I suspect I'm still missing a permission setting somewhere), as well as get the PDF information into the SQL database? Any suggestions would be greatly appreciated.
Thanks in advance.