我先拖放一个oracleConnection1控件到窗体上,在oracleConnection1的属性窗口中设置好连接,连的是oracle数据库,现在已经测试连通了,然后在Login_Load中要怎么写才能打开数据库?我是这样写的,不行,出错:
OracleConnection oracleConnection1 = new OracleConnection();
try
{
oracleConnection1.Open();
oracleConnection1.Close();
}
catch(OracleException exp)
{
oracleConnection1.Close();
throw exp;
}
OracleConnection oracleConnection1 = new OracleConnection();
try
{
oracleConnection1.Open();
oracleConnection1.Close();
}
catch(OracleException exp)
{
oracleConnection1.Close();
throw exp;
}
都是ado.net写的 和sqlserver一样 把sql改成oracle就可以
报的什么错啊 怎么不帖上来
末处理的"system.data.oracleclient.oracleexception"类型的异常出现在system.data.oracleclient.dell中我用控件能连上,用代码怎么连也连不上
现在用控件虽然连上了,但是在代码中用.open打不开啊
使用open 打開就行了
----------------------------
我非常不喜欢使用数据库控件,正常情况下我都是使用写好的操作数据库的类来操作sql server数据库,这一次要操作oracle,是实在没办法而为之,现在使用数据库控件,也只是判断一下到底能不能连接并打开oracle,如果能正确的打开数据库,我还是会改成代码来连的,并不是我懒连接数据库的代码虽然生成了,可是不管是使用数据库控件还是代码,我在.open的时候还是异常,非常奇怪,大家可以看一下我的代码(数据库能连上,就是打开时出错):
public bool testConnect()
{
OracleConnection conn = new OracleConnection("user id=app;data source=app;password=app;");
try
{
conn.Open();
conn.Close();
return true;
}
catch
{
conn.Close();
}
}
确定这个地方没写错吗?
问题应该就是这里里面!
OracleConnection conn = new OracleConnection("user id=app;data source=app;password=app;");
------------------------------------------------------
改到这样试试
OracleConnection conn = new OracleConnection("user id=app;data source=app;Integrated Security=yes;password=app;");