C#+ASP.NET+Oracle时积累的备忘点滴

    技术2022-05-11  104

    在asp.net中,如何回车触发指定按钮的事件? 假设: <asp:TextBox id="TextBox1" runat="server" Width="240px"></asp:TextBox> <asp:Button id="ButtonOK" runat="server" BorderWidth="1px" BorderColor="Purple" BorderStyle="Solid" Text="Search Site"></asp:Button>    解决方法: 在.aspx页面中添加: <SCRIPT LANGUAGE="javascript"> function EnterKeyClick(button)  {      if (event.keyCode == 13)   {           event.keyCode=9;   event.returnValue = false;   document.all[button].click();   } } </SCRIPT>    在Page_Load事件中添加: TextBox1.Attributes.Add("onkeydown","EnterKeyClick('ButtonOK');");   关于DATAGRID数据更改时点2次/行号跟不准/失去焦点/丢失e等一系列问题的解决办法: 首先把数据连接/dataadater等信息全放到void bindgrid中,其他地方不用if(!ISPOSTBACK),在PAGELOAD的时候只用个    if (!IsPostBack)    {        BindGrid();    } --------------------------------------------------------------------------------- 例如:  private void Page_Load(object sender, System.EventArgs e)   { if (!IsPostBack)    {BindGrid();}   }   private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)   { DataGrid1.EditItemIndex = e.Item.ItemIndex;    BindGrid();   }   private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)   { DataGrid1.EditItemIndex = -1;    BindGrid();   }   void BindGrid()    { oleDbDataAdapter1.Fill(dataSet11);    DataGrid1.DataBind();   }       在ASP.NET+ORACLE添加数据记录并让ID自动增量  在ASP.NET+ORACLE添加数据记录并让ID自动增量需要在ORACLE中设序列和触发器即可,切记不是索引,ASP.NET中不管ID,具体如下: 1、建立序列:  CREATE SEQUENCE seq_emergency_id  NOCYCLE  MAXVALUE 9999999999  START WITH 2;  2、建立触发器:  CREATE OR REPLACE TRIGGER set_emergency_id  BEFORE INSERT ON "EMERGENCY" FOR EACH ROW  DECLARE  next_emergency_id NUMBER;  BEGIN  --Get the next emergency id from the sequence  SELECT seq_emergency_id.NEXTVAL  INTO next_emergency_id  FROM dual;  --use the sequence number as the primary key  --for the record being inserted  :new.id := next_emergency_id;  END;  如果在企业管理器中创建,在触发器说明中填: DECLARE  next_emergencycb_id NUMBER;  BEGIN  --Get the next id number from the sequence  SELECT seq_emergencycb_id.NEXTVAL  INTO next_emergencycb_id  FROM dual;  --use the sequence number as the primary key  --for the record being inserted  :new.id := next_emergencycb_id;  END;     自己总结的常用ORACLE Text 文本检索 ORACLE Text 文本检索:(先要建立CONTEXT或CTXCAT索引,然后如下)(还可以在from前加,SCORE(10)来观察检索到的项目的得分) 1.单词的精确匹配检索 select cbid,title(列名) from emergency(表名) where contains(title,'关于')>0; 是从title中检索含词“关于”的cbid和title字段。 2.多个单词精确匹配 select cbid,title form emergency where contains(title,'关于 AND 请示')>0;是从title中检索含词“关于”和“请示”的上述字段。 也可select cbid,title form emergency where contains(title,'关于 AND 请示',NULL)>0;意思同上,不是检索短语而是两个单词,注意! 3.短语精确匹配 select cbid,title(列名) from emergency(表名) where contains(title,'doctor visits',NULL)>0;将精确匹配doctor visits短语 如果要用AND,OR,MINUS等保留字,应该使用转义符{},如doctor {and} visits   4.搜索互相接近的词语 select cbid,title(列名) from emergency(表名) where contains(title,'关于 NEAR 请示')>0; select cbid,title(列名) from emergency(表名) where contains(title,'NEAR((关于,请示),10)')>0;  是指指定的两个词在10个词之内 5.在搜索中使用通配符(多字符通配符是%,单字符通配符是-) select cbid,title(列名) from emergency(表名) where contains(title,'worker%')>0;是检索worker开头的单词,单字通配最多扩展3字符  6.模糊匹配搜索 select cbid,title(列名) from emergency(表名) where contains(title,'?关于')>0;  (前面得加一个问号) 7.使用ABOUT运算符来搜索文档的主题 select cbid,title form emergency where contains(title,'ABOUT(住房)',NULL)>0; 注意以上如果是用CONTEXT索引时,基表更新时文本索引并不更新,为了使索引同步,应该执行CTX_DLL程序包的SYNC_INDEX过程如下: EXECUTE CTX_DLL.SYNC_INDEX('REVIEW_INDEX');   C#委托的具体实现方法 (此处用无返回值的委托,如用有返回值的不同):   public  delegate  void processdelegate();//定义一个委托,一般不用pubic   public void chuli()//定义委托的匹配签名(事件处理)   {   Response.Write("aaaaaaaaaa");   }   在调用的时候先初始化委托并用new创建一个新委托然后将函数引用(事件处理)赋予委托变量或委托,执行委托   private void Button2_Click(object sender, System.EventArgs e)   {    processdelegate process;    process=new processdelegate(chuli); //   Response.Write("Result:{0}",process(param1,param2));//有返回值的一般这样执行    process();//无返回值的一般这样执行   }  

    最新回复(0)