您的位置:程序门 -> .net技术 -> c#



与oracle数据库的连接问题?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


与oracle数据库的连接问题?[已结贴,结贴人:wxmwy]
发表于:2007-01-10 19:59:16 楼主
各位我用c#与oracle做一个管理系统,在登陆界面时连接一次数据库,登陆成功到下一个界面因为需要显示一个表中数据又连接一次数据库,我是用最简单的连接方式做的连接,一点技术含量都没有,所以界面显示的很慢。我得怎么解决这个问题啊。各位帮帮忙啊
发表于:2007-01-10 20:06:191楼 得分:0
这个最好贴一些代码出来!
发表于:2007-01-10 20:11:122楼 得分:0
界面一:  
oracleconnection   css   =   dbEXECute.mainform_load();
          this.com   =       css.createcommand();
  com.commandtext   =   "select   *   from   table1   where   user_name   =   ' "+usernametext.text.trim()+ " '   and   password   =   ' "+passwordtest.text.trim()+ " ' ";
string   rs   =   (string)com.EXECutescalar();
if(rs!=null)
{       css.close();
console.writeline( "恭喜,登陆成功 ");    
this.hide();
        form2   f2   =   new   form2();
f2.showdialog();
                                this.dispose();

}
else   {
      messagebox.show( "您输入的用户名或密码有误 ");
}
界面2:
oledbconnection   con   =   new   oledbconnection( "provider=oraoledb.oracle.1;data   source=crds;user   id=automobile;password=automobile; ");
oledbdataadapter   sda   =   new   oledbdataadapter( "select   user_name   用户名,password   密码,name   姓名   from   table1   where   rownum <=10 ",   con);
dataset   ds   =   new   dataset();
        sda.fill(ds, "tabletaxt ");
this.datagrid1.datasource   =   ds.tables[ "tabletaxt "];

本人是个菜鸟   ,代码请多多指点
发表于:2007-01-10 20:11:323楼 得分:0
没什么问题..

不过也应该只第一次慢吧,第二次开连接时,系统会从数据库连接池中取

你数据太多?
发表于:2007-01-10 20:12:374楼 得分:0
programmer修佛家好还是修道家好?
发表于:2007-01-10 20:14:055楼 得分:0
一共就5条     开的很慢啊
发表于:2007-01-10 20:18:156楼 得分:0
我的两次连接方式不一样  
第一次用的方法是这个  
public   static   oracleconnection   mainform_load()
{
system.data.oracleclient.oracleconnection   cn=new   system.data.oracleclient.oracleconnection();
string   cnstring   = "user   id=username;data   source=data;password=password ";
cn.connectionstring=cnstring;
发表于:2007-01-10 20:24:397楼 得分:30
都用oracleclient下的,或者都用oledb下..
不然不是自找麻烦..

你开两个不一样的,每个在第一次开时难免都有些慢..
发表于:2007-01-10 20:30:498楼 得分:0
恩   ,   都用oledb速度果然上来了   谢谢你了


快速检索

最新资讯
热门点击