protected void btnSave_Click(object sender, EventArgs e) { ConnTest connTest = new ConnTest(); connTest.Name = txtName.Text; ConnTestDB db = new ConnTestDB(); if (db.Insert(connTest)) { lblMessage.Text = "Deu certo, amiguinho!"; txtName.Text = ""; } else { lblMessage.Text = "Ops, deu ruim!"; } }
public bool Insert(ConnTest connTest) { System.Data.IDbConnection objConn; System.Data.IDbCommand objCommand; string sql = "INSERT INTO teste_conexao(tes_nome) VALUES (?name)"; objConn = Mapped.Connection(); objCommand = Mapped.Command(sql, objConn); objCommand.Parameters.Add(Mapped.Parameter("?name", connTest.Name)); objCommand.ExecuteNonQuery(); objConn.Close(); objCommand.Dispose(); objConn.Dispose(); return(true); }