Visualizzazione dei risultati da 1 a 2 su 2

Discussione: [C# e .NET] update

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    258

    [C# e .NET] update

    Ciao a tutti, avrei bisogno d un suggerimento.
    Ho scritto questo codice x fare l'update ma entra sempre nel catch
    e se faccio un response.write di dell'sql nn mi sostituisci es.@len con 3

    Grazie
    _______

    public void Update_Click(object sender, DataGridCommandEventArgs e)
    {
    string id = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
    string cod = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
    string des = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
    string pfx = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
    int len = System.Convert.ToInt32(((TextBox)e.Item.Cells[6].Controls[0]).Text);
    int rfr = System.Convert.ToInt32(((TextBox)e.Item.Cells[7].Controls[0]).Text);
    int rto = System.Convert.ToInt32(((TextBox)e.Item.Cells[8].Controls[0]).Text);

    //update

    String updateCmd = "UPDATE Cla SET ClaCod = @cod ,ClaDes =@des, ClaPfx = @pfx, ClaLen = @len ,ClaRfr = @rfr ,ClaRto = @rto where ClaOwnId = @id";

    SqlCommand myCommand = new SqlCommand(updateCmd, conn);

    myCommand.Parameters.Add(new SqlParameter("@ClaCod", SqlDbType.VarChar,3)).Value = cod;
    myCommand.Parameters.Add(new SqlParameter("@ClaDes", SqlDbType.VarChar, 25)).Value = des;
    myCommand.Parameters.Add(new SqlParameter("@ClaPfx", SqlDbType.VarChar, 1)).Value = pfx;
    myCommand.Parameters.Add(new SqlParameter("@ClaLen", SqlDbType.Int)).Value = len ;
    myCommand.Parameters.Add(new SqlParameter("@ClaRfr", SqlDbType.Int )).Value = rfr;
    myCommand.Parameters.Add(new SqlParameter("@ClaRto", SqlDbType.Int)).Value = rto;

    try
    {
    conn.Open();
    myCommand.ExecuteNonQuery();
    }
    catch (SqlException exc)
    {
    Response.Write("ERRORE.");
    }
    conn.Close();
    ...
    ste

  2. #2
    ciao, ti informo che per discussioni legate al C# e al .NET Framework esiste l'apposito subforum. sposto lā.
    ...Terrible warlords, good warlords, and an english song

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.