Click here to Skip to main content
15,883,901 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ms access query to select between date Pin
Praveen Kandari4-Mar-15 17:40
Praveen Kandari4-Mar-15 17:40 
Questiontest Pin
Praveen Kandari3-Mar-15 0:52
Praveen Kandari3-Mar-15 0:52 
AnswerRe: test Pin
ZurdoDev3-Mar-15 2:39
professionalZurdoDev3-Mar-15 2:39 
QuestionAsyncFileUpload disappears Pin
anbusenthil2-Mar-15 15:43
anbusenthil2-Mar-15 15:43 
AnswerRe: AsyncFileUpload disappears Pin
F-ES Sitecore2-Mar-15 22:51
professionalF-ES Sitecore2-Mar-15 22:51 
QuestionReport Parameter not refreshing Pin
Kandepu Rajesh1-Mar-15 19:57
Kandepu Rajesh1-Mar-15 19:57 
AnswerRe: Report Parameter not refreshing Pin
Afzaal Ahmad Zeeshan2-Mar-15 3:12
professionalAfzaal Ahmad Zeeshan2-Mar-15 3:12 
QuestionMVC5 Website will write to the database on my development machine, but not on the web server Pin
jkirkerx1-Mar-15 13:33
professionaljkirkerx1-Mar-15 13:33 
I'm baffled by this.

I wrote a contact us page with a form, that writes the info to the table.
I can read the table, but I can't write to it on the production web server.
I can write to the table on my desktop running VS2013 Debug.

So I have 3 other databases on this production SQL server that works fine.
All the other web sites can read and write to the SQL same server.

It's just my first MVC App, that I wrote.
The function runs from the home controller and returns true, and sends the emails.
In web forms, it throws and exception if there's a mistake, but in my MVC app here, it just runs even if there is an error in the SQL.
Like I said I'm just baffled here on this.

[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Contact(ContactModel model, string returnUrl)
         {
             if (ModelState.IsValid && true == ContactExtender.SubmitContactMessage(model))
             {
                 // Package the data needed to send the message.
                 model.smtp_websiteName = "xxxxxx";
                 model.smtp_subject = "Contact Us";
                 model.smtp_sentFrom = "xxxxxx";
                 model.smtp_sendto = "xxxxxx";
                 model.smtp_replyto = "xxxxx";
                 model.smtp_templatePath_website = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SMTP_Templates/contact_website_template.html");
                 model.smtp_templatePath_customer = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SMTP_Templates/contact_customer_template.html");

                 // Send a email message to me and the customer.
                 bool website = Contact_Website_Email_Proc.Send_XHTML_Website_Message(model);
                 bool visitor = Contact_Customer_Email_Proc.Send_XHTML_Customer_Message(model);

                 ViewData["contactMessage"] = "Success";
                 //return RedirectToLocal(returnUrl);
             }
             else
             {
                 ViewData["contactMessage"] = "Failed";
                
             }
             return View(model);
        }


public static bool SubmitContactMessage(ContactModel  cm)
        {
            bool success = false;
            string connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection conn = new SqlConnection(connStr);

            string query =
            "INSERT INTO CRM_MESSAGES " +
            "( " +
            "   Name " +
            "   , Subject " +
            "   , CompanyName " +
            "   , EmailAddress " +
            "   , Query " +
            "   , Date " +
            "   , MailingList " +
            ") " +
            "VALUES " +
            "( " +
            "   @Name " +
            "   , @Subject " +
            "   , @CompanyName " +
            "   , @EmailAddress " +
            "   , @Query " +
            "   , @Date " +
            "   , @MailingList " +
            ") ";            

            SqlCommand cmd = new SqlCommand(query, conn);

            cmd.Parameters.Add(new SqlParameter("@Name", cm.Name));
            cmd.Parameters.Add(new SqlParameter("@Subject", "ContactUs"));
            cmd.Parameters.Add(new SqlParameter("@CompanyName", cm.CompanyName));
            cmd.Parameters.Add(new SqlParameter("@EmailAddress", cm.EmailAddress));
            cmd.Parameters.Add(new SqlParameter("@Query", cm.Query));
            cmd.Parameters.Add(new SqlParameter("@Date", DateTime.Now));
            cmd.Parameters.Add(new SqlParameter("@MailingList", cm.MailingList));

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();                
                success = true;



            }
            catch (Exception)
            {
                success = false;
            }
            finally
            {
                conn.Close();

            }

            return success;
        }

AnswerRe: MVC5 Website will write to the database on my development machine, but not on the web server Pin
F-ES Sitecore1-Mar-15 23:48
professionalF-ES Sitecore1-Mar-15 23:48 
GeneralRe: MVC5 Website will write to the database on my development machine, but not on the web server Pin
jkirkerx2-Mar-15 6:05
professionaljkirkerx2-Mar-15 6:05 
Answer[solved] Pin
jkirkerx2-Mar-15 9:14
professionaljkirkerx2-Mar-15 9:14 
Questionajaxtoolkit ModalPopupExtender problem Pin
casa_sniper1-Mar-15 5:13
casa_sniper1-Mar-15 5:13 
AnswerRe: ajaxtoolkit ModalPopupExtender problem Pin
casa_sniper1-Mar-15 10:43
casa_sniper1-Mar-15 10:43 
QuestionModalPopupExtender problem Pin
casa_sniper1-Mar-15 5:13
casa_sniper1-Mar-15 5:13 
AnswerRe: ModalPopupExtender problem Pin
casa_sniper5-May-15 14:37
casa_sniper5-May-15 14:37 
QuestionScript Resource Mappings Not Loading From CDN Pin
Dominick Marciano28-Feb-15 18:05
professionalDominick Marciano28-Feb-15 18:05 
QuestionPlease Help!!!- with an empty web site small task Pin
Amir87657428-Feb-15 12:52
Amir87657428-Feb-15 12:52 
AnswerRe: Please Help!!!- with an empty web site small task Pin
Richard Andrew x6428-Feb-15 17:37
professionalRichard Andrew x6428-Feb-15 17:37 
Question[ERROR] An attempt to attach an auto-named database for file <path>.mdf failed ... or it is locat... Pin
Atinesh28-Feb-15 7:48
Atinesh28-Feb-15 7:48 
Generalwhen i host my application in iis local host but on the same computer it is open very slow Pin
tarun kumar sahu hs28-Feb-15 6:22
tarun kumar sahu hs28-Feb-15 6:22 
SuggestionA few points to consider while working with literal string in ASP.NET Pin
Afzaal Ahmad Zeeshan28-Feb-15 3:28
professionalAfzaal Ahmad Zeeshan28-Feb-15 3:28 
GeneralRe: A few points to consider while working with literal string in ASP.NET Pin
Richard MacCutchan28-Feb-15 5:44
mveRichard MacCutchan28-Feb-15 5:44 
GeneralRe: A few points to consider while working with literal string in ASP.NET Pin
Afzaal Ahmad Zeeshan28-Feb-15 5:52
professionalAfzaal Ahmad Zeeshan28-Feb-15 5:52 
GeneralRe: A few points to consider while working with literal string in ASP.NET Pin
Richard MacCutchan28-Feb-15 6:47
mveRichard MacCutchan28-Feb-15 6:47 
GeneralRe: A few points to consider while working with literal string in ASP.NET Pin
Afzaal Ahmad Zeeshan28-Feb-15 6:53
professionalAfzaal Ahmad Zeeshan28-Feb-15 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.