Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
QuestionCommand Question Pin
Kevin Marois9-Mar-12 7:01
professionalKevin Marois9-Mar-12 7:01 
Questionlistview Pin
abiir9-Mar-12 5:53
abiir9-Mar-12 5:53 
AnswerRe: listview Pin
Dave Kreskowiak9-Mar-12 7:14
mveDave Kreskowiak9-Mar-12 7:14 
AnswerRe: listview Pin
Abhinav S9-Mar-12 15:45
Abhinav S9-Mar-12 15:45 
Questionstreaming video with c# Pin
sileen_Mohammad9-Mar-12 5:32
sileen_Mohammad9-Mar-12 5:32 
AnswerRe: streaming video with c# Pin
Abhinav S9-Mar-12 5:37
Abhinav S9-Mar-12 5:37 
GeneralRe: streaming video with c# Pin
sileen_Mohammad10-Mar-12 8:37
sileen_Mohammad10-Mar-12 8:37 
QuestionC# ASP.net Update Data into a SQL server database Pin
Mike9889-Mar-12 4:52
Mike9889-Mar-12 4:52 
Hi, I have a problem with my homework assignment.
I am able to access the database and insert new customer but it doesn't work when i try to update any record.
if anyone can tell me what is wrong with my code.
thank you so much

this is all my code

C#
 protected void btnUpdate_Click(object sender, EventArgs e)
    {
<big>//this is my problem//</big>
 

        if (Request.QueryString["id"] != null)
        {
            
                        
                 //Declare the connection object
                 SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyLocal"].ConnectionString);
 
                 //Make the connection 
                 Conn.Open();
 
                 //Define you query
              
              
                 string sql = "UPDATE [Customer] SET [FirstName] = @FirstName,  [LastName] = @LastName, [Email] = @Email, [Password] = @Password, [Address1] = @Address1, [Address2] = @Address2, [City] = @City, [State] = @State, [zip] = @zip, [Phone] = @Phone, [Fax] = @Fax  WHERE CustomerID=@CustomerID";
                
                 
                 
                 //Declare the Command
                 SqlCommand cmd = new SqlCommand(sql, Conn);
 
                 //Add the parameters needed for the SQL query
                  cmd.Parameters.AddWithValue("@CustomerID", CustomerID);
                   cmd.Parameters.AddWithValue("@FirstName", txtFirstName.Text);
                  cmd.Parameters.AddWithValue("@LastName", txtLastName.Text);
                  cmd.Parameters.AddWithValue("@Email", txtEmailA.Text);
                  cmd.Parameters.AddWithValue("@Password", txtPasswordA.Text);
                  cmd.Parameters.AddWithValue("@Address1", txtAddress1.Text);
                  cmd.Parameters.AddWithValue("@Address2", txtAddress2.Text);
                   cmd.Parameters.AddWithValue("@City", txtCity.Text);
                  cmd.Parameters.AddWithValue("@State", txtState.Text);
                   cmd.Parameters.AddWithValue("@Zip", txtZip.Text);
                  cmd.Parameters.AddWithValue("@Phone", txtPhone.Text);
                   cmd.Parameters.AddWithValue("@Fax", txtFax.Text);
 

 
                 //Execute the query
 
                 cmd.ExecuteNonQuery();
 
                 Conn.Close();
                 Response.Redirect("Customers.aspx");
             
         
 
        }


modified 9-Mar-12 12:04pm.

AnswerRe: C# ASP.net Update Data into a SQL server database Pin
Wes Aday9-Mar-12 5:29
professionalWes Aday9-Mar-12 5:29 
Generali need help???in c# Pin
amira luis9-Mar-12 0:25
amira luis9-Mar-12 0:25 
GeneralRe: i need help???in c# Pin
OriginalGriff9-Mar-12 0:27
mveOriginalGriff9-Mar-12 0:27 
AnswerRe: i need help???in c# Pin
V.9-Mar-12 1:59
professionalV.9-Mar-12 1:59 
GeneralRe: i need help???in c# Pin
Wes Aday9-Mar-12 3:03
professionalWes Aday9-Mar-12 3:03 
Questioninteracting with a webiste in c# Pin
james bradbery8-Mar-12 21:21
james bradbery8-Mar-12 21:21 
AnswerRe: interacting with a webiste in c# Pin
Dave Kreskowiak9-Mar-12 3:16
mveDave Kreskowiak9-Mar-12 3:16 
QuestionThe WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
MarkSquall8-Mar-12 18:58
MarkSquall8-Mar-12 18:58 
AnswerRe: The WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
Bernhard Hiller8-Mar-12 21:26
Bernhard Hiller8-Mar-12 21:26 
GeneralRe: The WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
Sentenryu9-Mar-12 0:21
Sentenryu9-Mar-12 0:21 
AnswerRe: The WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
Shameel9-Mar-12 1:03
professionalShameel9-Mar-12 1:03 
AnswerRe: The WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
jschell9-Mar-12 5:16
jschell9-Mar-12 5:16 
AnswerRe: The WebService still returns "Connection Successful" even SQL Server is off. Please Help. Pin
MarkSquall11-Mar-12 21:33
MarkSquall11-Mar-12 21:33 
QuestionEncryption and decryption Pin
sandy_418-Mar-12 17:19
sandy_418-Mar-12 17:19 
AnswerRe: Encryption and decryption PinPopular
OriginalGriff8-Mar-12 20:20
mveOriginalGriff8-Mar-12 20:20 
GeneralRe: Encryption and decryption Pin
sandy_419-Mar-12 0:12
sandy_419-Mar-12 0:12 
GeneralRe: Encryption and decryption Pin
OriginalGriff9-Mar-12 0:25
mveOriginalGriff9-Mar-12 0:25 

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.