首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

求一ORACLE的连接程序,该如何解决

2011-12-30 
求一ORACLE的连接程序本人在c#.net中建立了个windows应用程序。现在要用他连接个ORACLE总不太成功。有高手能

求一ORACLE的连接程序
本人在c#.net中建立了个windows应用程序。现在要用他连接个ORACLE总不太成功。
有高手能写个能用的给我吗?

我发下我写的大家指正下。
private   void   Form1_Load(object   sender,   System.EventArgs   e)
{

try
{
string   ConnectionString= "User   ID=sang;Data   Source= 'oracle_10.40.18.24 ';Password=sang; ";//写连接串
OracleConnection   conn=new   oracleConnection(ConnectionString);
//connection   =   new   OracleConnection( "User   ID=sang;Data   Source= 'oracle_10.40.18.24 ';Password=sang; ");

//Provider= "MSDAORA.1 ";User   ID=sang;Data   Source= "oracle_10.40.18.24 ";Password=sang
//写连接串
//OracleDataAdapter   dataAdapter   =   new   OracleDataAdapter( "select   *   from   TEXT ",connection);
//创建一个新连接

conn.Open();

OracleCommand   cmd   =   conn.CreateCommand();


cmd.CommandText= "select   *   from   TEXT ";  
//在这儿写sql语句
OracleDataReader   odr=cmd.ExecuteReader();  
//创建一个OracleDateReader对象
//
//this.comboBox1.DataSource   =   odr;
//this.comboBox1.DisplayMember   =   "guojia ";
//this.comboBox1.ValueMember   =   "guojia ";
////this.comboBox1.DataBindings;



//
//while(odr.Read())
////读取数据,如果odr.Read()返回为false的话,就说明到记录集的尾部了                    
//{
//Response.Write(odr.GetOracleString(1).ToString());
////输出字段1,这个数是字段索引
//}
odr.Close();
}
catch(Exception   ex)  
{  
MessageBox.Show( "e ");

}
finally
{
conn.Close();   //关闭连接
}
}


[解决办法]
oracle_10.40.18.24
external dbid length 18 is greater than maximum (16)

--最大长度16位,你定义了18位
--改称短点的名字测试一下


热点排行