troubleshooting Question

ASP.NET Update Query Not Working

Avatar of karthik80c
karthik80cFlag for United States of America asked on
.NET ProgrammingASP.NETC#Microsoft SQL ServerWeb Development
15 Comments4 Solutions150 ViewsLast Modified:
Hi ASP Experts,

Am doing a simple update query in csharp and code alerts its updated the data  but its really not updated the value .

 string id = Request.QueryString["id"];
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
        SqlCommand cmd = new SqlCommand("UPDATE [dbo].[Lead] SET [LeadOwner] = @LeadOwner, [LeadOwnerId] = @LeadOwnerId, [Company] = @Company, [FirstName] = @FirstName, [LastName] = @LastName, [Email] = @Email, [Phone] = @Phone, [Mobile] = @Mobile, [Website] = @Website, [LeadSource] = @LeadSource, [LeadStatus] = @LeadStatus,  [ModifiedBy] = @ModifiedBy, [ModifiedById] = @ModifiedById, [ModifiedTime] = @ModifiedTime, [Street] = @Street, [PostalCode] = @PostalCode, [Description] = @Description, [LastActivityTime] = @LastActivityTime, [TakenBy] = @TakenBy, [Subject] = @Subject, [Suburb] = @Suburb, [States] = @States, [PropertyType] = @PropertyType, [AgentContacted] = @AgentContacted WHERE [Ld_id] = @id", con);
        con.Open();
                    cmd.Parameters.AddWithValue("@id", id);
                    cmd.Parameters.AddWithValue("@LeadOwner", LeadOwner.Text);
                    cmd.Parameters.AddWithValue("@LeadOwnerId", DBNull.Value);
                    cmd.Parameters.AddWithValue("@Company", Company.Text);
                    cmd.Parameters.AddWithValue("@FirstName", FirstName.Text);
                    cmd.Parameters.AddWithValue("@LastName", LastName.Text);
                    cmd.Parameters.AddWithValue("@Email", Email.Text);
                    cmd.Parameters.AddWithValue("@Phone", Phone.Text);
                    cmd.Parameters.AddWithValue("@Mobile", Mobile.Text);
                    cmd.Parameters.AddWithValue("@Website", Website.Text);
                    cmd.Parameters.AddWithValue("@LeadSource", LeadSource.Text);
                    cmd.Parameters.AddWithValue("@LeadStatus", LeadStatus.Text);
                    cmd.Parameters.AddWithValue("@ModifiedBy",DBNull.Value);
                    cmd.Parameters.AddWithValue("@ModifiedById", DBNull.Value);
                    cmd.Parameters.AddWithValue("@ModifiedTime", DateTime.Now.ToString("h:mm:ss tt"));
                    cmd.Parameters.AddWithValue("@Street", Street.Text);
                    cmd.Parameters.AddWithValue("@PostalCode", PostalCode.Text);
                    cmd.Parameters.AddWithValue("@Description", Description.Text);
                    cmd.Parameters.AddWithValue("@LastActivityTime", DateTime.Now.ToString("h:mm:ss tt"));
                    cmd.Parameters.AddWithValue("@TakenBy", Taken.Text);
                    cmd.Parameters.AddWithValue("@Subject", Subject.Text);
                    cmd.Parameters.AddWithValue("@Suburb", Suburb.Text);
                    cmd.Parameters.AddWithValue("@States", States.Text);
                    cmd.Parameters.AddWithValue("@PropertyType", PropertyType.Text);
                    cmd.Parameters.AddWithValue("@AgentContacted", AgentContacted.Text);

                    int a = cmd.ExecuteNonQuery();
                    if (a == 0)
                    {
                        Response.Write("sorry");
                        con.Close();

                    }
                    else
                    {
                        Response.Write("done");
                        con.Close();

                    }

Open in new window


Thanks in Advance
ASKER CERTIFIED SOLUTION
Lokesh B R
Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2015

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 4 Answers and 15 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 4 Answers and 15 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004