现在我的开发环境是:
vs.net 2003。Oracle8i server(远程服务器),本机的客户端也是oracle8i client,win2000。
我在vb.net中加入:
Imports System.Data.OracleClient
Imports System.Data.OleDb
Imports System.Data
然后用:
(方法1):
Dim oOleDbConnection As OleDb.OleDbConnection
Dim sConnString As String = _
"Provider=OraOLEDB.Oracle;" & _
"Data Source=Orcale;" & _
"User ID=afccc/afccc;" & _
"Password=afccc2"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
总是报错如下:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。
(方法2):
Dim conn As New System.Data.OracleClient.OracleConnection
conn.ConnectionString = "user id=afccc;data ource=glb_ticketinfo;password=afccc2;"
conn.Open()
总是报错如下:
未处理的“System.Data.OracleClient.OracleException”类型的异常出现在
system.data.oracleclient.dll 中。其他信息: 系统错误。
两种方法都不行,请哪位高手指教小弟一把。
希望能提供代源更好。
7 个解决方案
#1
dim connstr=Provider=OraOLEDB.Oracle.1;Data Source=***;User ID=***;Password=***;Persist Security Info=True
至于连接串的写法你可以新建一个udl文件,然后进行一下配置,将配置信息取出来就是上面的内容。如果在udl文件里面测试连接通过,而你在conn.open的时候报错的话,你看一下mdac2.7有没有装。(如果提示mdac版本问题的话)
至于连接串的写法你可以新建一个udl文件,然后进行一下配置,将配置信息取出来就是上面的内容。如果在udl文件里面测试连接通过,而你在conn.open的时候报错的话,你看一下mdac2.7有没有装。(如果提示mdac版本问题的话)
#2
Try
Dim conn As New System.Data.OracleClient.OracleConnection
conn.ConnectionString = "user id=afccc;data ource=glb_ticketinfo;password=afccc2;"
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
先看看详细的错误信息~~~~
Dim conn As New System.Data.OracleClient.OracleConnection
conn.ConnectionString = "user id=afccc;data ource=glb_ticketinfo;password=afccc2;"
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
先看看详细的错误信息~~~~
#3
Public Function DB_Connect() As Boolean
On Error GoTo Err_DB_Connect
Dim strMsg As String
Dim User As String
Dim Pass As String
Dim Host As String
Dim UserPass As String
Dim Ret As Integer
User = ReadIniFile(LoadIni, "ORACLE", "USER")
Pass = ReadIniFile(LoadIni, "ORACLE", "PASS")
Host = ReadIniFile(LoadIni, "ORACLE", "HOST")
UserPass = User & "/" & Pass
DB_Connect = False
oraSes = CType(CreateObject("OracleInProcServer.XOraSession"), OracleInProcServer.OraSession)
oraDb = CType(oraSes.OpenDatabase(Host, UserPass, OracleInProcServer.dbOption.ORADB_ORAMODE), OracleInProcServer.OraDatabase)
DB_Connect = True
Exit Function
Err_DB_Connect:
On Error Resume Next
End Function
这个方法需要OracleInProcServer,所以自己加一下!
On Error GoTo Err_DB_Connect
Dim strMsg As String
Dim User As String
Dim Pass As String
Dim Host As String
Dim UserPass As String
Dim Ret As Integer
User = ReadIniFile(LoadIni, "ORACLE", "USER")
Pass = ReadIniFile(LoadIni, "ORACLE", "PASS")
Host = ReadIniFile(LoadIni, "ORACLE", "HOST")
UserPass = User & "/" & Pass
DB_Connect = False
oraSes = CType(CreateObject("OracleInProcServer.XOraSession"), OracleInProcServer.OraSession)
oraDb = CType(oraSes.OpenDatabase(Host, UserPass, OracleInProcServer.dbOption.ORADB_ORAMODE), OracleInProcServer.OraDatabase)
DB_Connect = True
Exit Function
Err_DB_Connect:
On Error Resume Next
End Function
这个方法需要OracleInProcServer,所以自己加一下!
#4
具体是哪行报错?
#5
Dim strconn As String = "Provider=MSDAORA;Password=密码;User ID=用户名;Data Source=数据源"
Dim myconn As OleDbConnection = New OleDbConnection(strconn)
Dim ds As DataSet = New DataSet()
Dim sql As String = "select * from usermanager where userid='" + userid.Text.Trim + "' and pwd='" + pwd.Text.Trim + "' and area='" + userzone.SelectedItem.Text + "'"
Dim adpt As OleDbDataAdapter = New OleDbDataAdapter(sql, myconn)
Dim find_flag As Boolean = False
Try
adpt.Fill(ds)
Catch errmsg As Exception
msg.Text = errmsg.Message
Finally
myconn.Close()
End Try
试试呢?应该可以的
Dim myconn As OleDbConnection = New OleDbConnection(strconn)
Dim ds As DataSet = New DataSet()
Dim sql As String = "select * from usermanager where userid='" + userid.Text.Trim + "' and pwd='" + pwd.Text.Trim + "' and area='" + userzone.SelectedItem.Text + "'"
Dim adpt As OleDbDataAdapter = New OleDbDataAdapter(sql, myconn)
Dim find_flag As Boolean = False
Try
adpt.Fill(ds)
Catch errmsg As Exception
msg.Text = errmsg.Message
Finally
myconn.Close()
End Try
试试呢?应该可以的
#6
http://dev.csdn.net/develop/article/16/16437.shtm
.NET中各种数据库连接大全
.NET中各种数据库连接大全
#7
最簡單的方法,用向導的方法生成....
然後將向導生成的代碼裡 連接到 oracle 的代碼copy 下來用就OK 了...
然後將向導生成的代碼裡 連接到 oracle 的代碼copy 下來用就OK 了...
#1
dim connstr=Provider=OraOLEDB.Oracle.1;Data Source=***;User ID=***;Password=***;Persist Security Info=True
至于连接串的写法你可以新建一个udl文件,然后进行一下配置,将配置信息取出来就是上面的内容。如果在udl文件里面测试连接通过,而你在conn.open的时候报错的话,你看一下mdac2.7有没有装。(如果提示mdac版本问题的话)
至于连接串的写法你可以新建一个udl文件,然后进行一下配置,将配置信息取出来就是上面的内容。如果在udl文件里面测试连接通过,而你在conn.open的时候报错的话,你看一下mdac2.7有没有装。(如果提示mdac版本问题的话)
#2
Try
Dim conn As New System.Data.OracleClient.OracleConnection
conn.ConnectionString = "user id=afccc;data ource=glb_ticketinfo;password=afccc2;"
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
先看看详细的错误信息~~~~
Dim conn As New System.Data.OracleClient.OracleConnection
conn.ConnectionString = "user id=afccc;data ource=glb_ticketinfo;password=afccc2;"
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
先看看详细的错误信息~~~~
#3
Public Function DB_Connect() As Boolean
On Error GoTo Err_DB_Connect
Dim strMsg As String
Dim User As String
Dim Pass As String
Dim Host As String
Dim UserPass As String
Dim Ret As Integer
User = ReadIniFile(LoadIni, "ORACLE", "USER")
Pass = ReadIniFile(LoadIni, "ORACLE", "PASS")
Host = ReadIniFile(LoadIni, "ORACLE", "HOST")
UserPass = User & "/" & Pass
DB_Connect = False
oraSes = CType(CreateObject("OracleInProcServer.XOraSession"), OracleInProcServer.OraSession)
oraDb = CType(oraSes.OpenDatabase(Host, UserPass, OracleInProcServer.dbOption.ORADB_ORAMODE), OracleInProcServer.OraDatabase)
DB_Connect = True
Exit Function
Err_DB_Connect:
On Error Resume Next
End Function
这个方法需要OracleInProcServer,所以自己加一下!
On Error GoTo Err_DB_Connect
Dim strMsg As String
Dim User As String
Dim Pass As String
Dim Host As String
Dim UserPass As String
Dim Ret As Integer
User = ReadIniFile(LoadIni, "ORACLE", "USER")
Pass = ReadIniFile(LoadIni, "ORACLE", "PASS")
Host = ReadIniFile(LoadIni, "ORACLE", "HOST")
UserPass = User & "/" & Pass
DB_Connect = False
oraSes = CType(CreateObject("OracleInProcServer.XOraSession"), OracleInProcServer.OraSession)
oraDb = CType(oraSes.OpenDatabase(Host, UserPass, OracleInProcServer.dbOption.ORADB_ORAMODE), OracleInProcServer.OraDatabase)
DB_Connect = True
Exit Function
Err_DB_Connect:
On Error Resume Next
End Function
这个方法需要OracleInProcServer,所以自己加一下!
#4
具体是哪行报错?
#5
Dim strconn As String = "Provider=MSDAORA;Password=密码;User ID=用户名;Data Source=数据源"
Dim myconn As OleDbConnection = New OleDbConnection(strconn)
Dim ds As DataSet = New DataSet()
Dim sql As String = "select * from usermanager where userid='" + userid.Text.Trim + "' and pwd='" + pwd.Text.Trim + "' and area='" + userzone.SelectedItem.Text + "'"
Dim adpt As OleDbDataAdapter = New OleDbDataAdapter(sql, myconn)
Dim find_flag As Boolean = False
Try
adpt.Fill(ds)
Catch errmsg As Exception
msg.Text = errmsg.Message
Finally
myconn.Close()
End Try
试试呢?应该可以的
Dim myconn As OleDbConnection = New OleDbConnection(strconn)
Dim ds As DataSet = New DataSet()
Dim sql As String = "select * from usermanager where userid='" + userid.Text.Trim + "' and pwd='" + pwd.Text.Trim + "' and area='" + userzone.SelectedItem.Text + "'"
Dim adpt As OleDbDataAdapter = New OleDbDataAdapter(sql, myconn)
Dim find_flag As Boolean = False
Try
adpt.Fill(ds)
Catch errmsg As Exception
msg.Text = errmsg.Message
Finally
myconn.Close()
End Try
试试呢?应该可以的
#6
http://dev.csdn.net/develop/article/16/16437.shtm
.NET中各种数据库连接大全
.NET中各种数据库连接大全
#7
最簡單的方法,用向導的方法生成....
然後將向導生成的代碼裡 連接到 oracle 的代碼copy 下來用就OK 了...
然後將向導生成的代碼裡 連接到 oracle 的代碼copy 下來用就OK 了...