Ash

Ash

  • NA
  • 2
  • 0

Can you spot my error please

Aug 7 2006 5:08 PM
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { private string _connectionString = ConfigurationSettings.AppSettings["ConnectionString"]; protected void Page_Load(object sender, System.EventArgs e) { if (!(Page.IsPostBack)) GetData(); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { } #endregion private void GetData() { SqlConnection connection = null; SqlCommand command = null; SqlDataReader reader = null; SqlParameter parameter = null; try { connection = new SqlConnection(_connectionString); connection.Open(); command = new SqlCommand("select * from nametable where id = @id", connection); parameter = new SqlParameter("@id", SqlDbType.Int); parameter.Value = 1; command.Parameters.Add(parameter); reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) { reader.Read(); nameTextBox.Text = Convert.ToString(reader["name"]); } } catch (Exception ex) { // throw; } finally { if (reader != null) ((IDisposable)reader).Dispose(); if (connection != null) { if (connection.State == ConnectionState.Open) connection.Close(); connection.Dispose(); } } } private void UpdateData() { SqlConnection connection = null; SqlCommand command = null; SqlParameter parameter = null; try { connection = new SqlConnection(_connectionString); connection.Open(); command = new SqlCommand("update nametable set Name.name = @Name where id = @id", connection); parameter = new SqlParameter("@Name", SqlDbType.VarChar); parameter.Value = nameTextBox.Text; command.Parameters.Add(parameter); parameter = new SqlParameter("@id", SqlDbType.Int); parameter.Value = 1; command.Parameters.Add(parameter); command.ExecuteNonQuery(); } catch (Exception ex) { finally { if (connection != null) { if (connection.State == ConnectionState.Open) connection.Close(); connection.Dispose(); } } protected void TextBox1_TextChanged(object sender, EventArgs e) { Label1.Text = nameTextBox.Text; } protected void updateButton_Click(object sender, EventArgs e) { UpdateData(); } } *** i keep getting this stupid message : Error 1 } expected *** pls help

Answers (2)