简体   繁体   English

表格更改后GridView不更新

[英]gridview not updating after table alter

the below code is what i've written to populate a gridview with the values from the oracle database when i click a button. 下面的代码是我单击按钮时用oracle数据库中的值填充gridview的内容。 the problem im facing is that, when i delete rows in the table from "sqlplus" manually and then click the button it is still showing the values that i enterd previously and not an empty grid.im quite new to gridview so please help me out 我面临的问题是,当我手动从“ sqlplus”中删除表中的行,然后单击按钮时,它仍显示我之前输入的值,而不是一个空的grid.im,对于gridview来说不是很新,所以请帮帮我

protected void Button1_Click(object sender, EventArgs e)
{
    string v =System.Configuration.ConfigurationManager.ConnectionStrings["harish"].ConnectionString;
    con = new OracleConnection(v);
    con.Open(); 
    cmd = new OracleCommand("select *  from leave_module1 order by name", con);
    dr = cmd.ExecuteReader();

    GridView1.DataSource=dr;
    GridView1.DataBind();
    con.Close();
    dr.Close();




}

You must fire a commit after you delete rows in sqlplus. 在sqlplus中删除行之后,必须触发提交。

If you delete and run a select, you won't see any rows in that session. 如果删除并运行选择,则该会话中将看不到任何行。 But your rows are not really deleted yet. 但是您的行尚未真正删除。

They will be deleted from the actual table only after you ask sqlplus to commit your changes. 仅在您要求sqlplus提交更改后,它们才会从实际表中删除。

This is needed cause oracle doesn't auto-commit by default. 这是必需的,因为默认情况下oracle不会自动提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM