日期:2014-05-20  浏览次数:20576 次

终于可以从oracle数据库返回东西了,但怎么得到是这些东东?
想开发一个基于PDA的网站,测试用asp.net连接oracle数据库,想试一下从一个表中取些东西显示出来,上午因为conectstr里一个分号的问题,郁闷了半天,现在终于可以正确往dataset里填东西了,但是我还不是太会用dataadapater.得到东西是这样的。
System.Data.DataRowView  
System.Data.DataRowView  
System.Data.DataRowView  
System.Data.DataRowView  

数据库名是bak,表名是SEX_DICT,我在asp.net中用了个list控件,整个代码如下,请帮忙指点怎么用list控件把表的内容显示出来。

//数据库连接
string   query   =   "select   *   from   SEX_DICT ";
string   myConectiongStr   =   "server=132.147.0.8;Data   Source=bak;
uid=kyb;   pwd=boy ";
OracleConnection   conn   =   new   OracleConnection(myConectiongStr);
//声明dataset
DataSet   myDataSet   =   new   DataSet();
//声明一个dataAdapter
OracleDataAdapter   myDateAdapter   =   new   OracleDataAdapter(query,   conn);
//打开连接,填充dataset
conn.Open();
int   i=   myDateAdapter.Fill(myDataSet, "SEX_DICT ");
conn.Close();
//把它显示出来,简单这么绑定可以吗?该怎么显示呢?
MyList.DataSource   =   myDataSet.Tables[0].DefaultView;
MyList.DataBind();

SEX_DICT描述是
SERIAL_NO
SEX_CODE
SEX_NAME
INPUT_CODE

谢谢大家的指教!




------解决方案--------------------
我的异常网推荐解决方案:oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html
------解决方案--------------------
注意代码顺序,先绑定在conn.Close();

------解决方案--------------------
Imports System.Data.OracleClient
Imports cBaseService
'Imports System.Data.oracle

Friend Class OracleDB
#Region " 变量 "
Private WithEvents DBConn As OracleConnection
Private WithEvents DbCmd As OracleCommand
Private WithEvents DbExec As OracleCommand

Public Structure ProcCommandParam
Public [Name] As String
Public [DataType] As System.Data.DbType
Public [Value] As Object

Public Sub New(ByVal ParamName As String, Optional ByVal ParamType As System.Data.DbType = DbType.String, Optional ByVal ParamValue As Object = " ")
[Name] = ParamName
[DataType] = ParamType
[Value] = ParamValue
End Sub

Public ReadOnly Property Length() As Int32
Get
Return [Name].Length + [Value].ToString.Length
End Get
End Property

Public Function ToSQLParameter() As OracleParameter
Return New OracleParameter([Name], CType([DataType], SqlDbType), [Value])
End Function
End Structure
#End Region

#Region " 构造函数 "
Public Sub New()
DBConn = New OracleConnection
DbCmd = New OracleCommand
DbExec = New OracleCommand
End Sub

Public Sub Dispose()
If Not DBConn Is Nothing Then DBConn.Close() : DBConn.Dispose()
If Not DbCmd Is Nothing Then DbCmd.Dispose()
If Not DbExec Is Nothing Then DbExec.Dispose()
End Sub
#End Region

#Region " 数据连接 "

' <WebMethod(Description:= "连接数据库 ")> _
Public Function Connect() As Boolean
Try
DBConn.ConnectionString = GetConnectionString()
DBConn.Open()
Return True
Catch ex As Exception
BackError(DBConn.ConnectionString, ex.Message)
Throw ex
Return False
End Try
End Function

' <WebMethod(Description:= "关闭与数据库的连接 ")> _
Public Function DisConnect()