下面这个SQL语句具体的含义是什么呢?
急、急 在线等Dim dt As DataSet = dbm.GetRs("select t.* from t_sssx t", "", "") --------------------编程问答-------------------- 定义了一个DataSet变量DT,并给DT赋值
dbm.GetRs() 应该是自定义的类,其中 dbm是类名 getrs是类中的方法或者函数,作用就是根据传递的sql语句,例如你上面的“select * from t_sssx t","",""”查询数据库,然后将数据填入ds,最终赋值给dt --------------------编程问答-------------------- 返回t_sssx表的所有数据。 --------------------编程问答--------------------
非常感谢楼上两位的解答,可以当程序运行到下面红色标记处时,会提示错误Fill: SelectCommand.Connection 属性尚未初始化,这是第二次运行时给出的错误提示,第一次运行时的错误提示是“未将对象引用设置到对象实例”
Public Function GetRs(ByVal strSql As String, Optional ByVal strSqlFilter As String = "", _
Optional ByVal strSqlGroupBy As String = "", Optional ByVal strSqlOrderBy As String = "") As System.Data.DataSet
Dim ds As System.Data.DataSet = Nothing
Try
Me.GetDataAdapter(strSql, strSqlFilter, strSqlGroupBy, strSqlOrderBy)
If Not dataAdapter Is Nothing Then
ds = New System.Data.DataSet
dataAdapter.Fill(ds)
Return ds
Else
Return Nothing
End If
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
Return Nothing
Finally
DisposeDataAdapter(dataAdapter)
End Try
End Function
--------------------编程问答-------------------- 属性尚未初始化 --------------------编程问答-------------------- Private Function getSxssTable() As DataTable
Dim dbm As DBManager.PropDbManager = New PropDbManager(enumDatabaseType.propDatabaseOracle, GlobalConst.getStrCnn(1))这个地方我不是已经给属性初始化了吗
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Dim dt As DataSet = dbm.GetRs("select t.* from t_sssx t", "", "")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim dt As DataSet = dbm.GetRs("select t.* from t_sssx t", "", "")
dt.Tables(0).Columns(0).ReadOnly = True
Return dt.Tables(0)
End Function
Public Function GetRs(ByVal strSql As String, Optional ByVal strSqlFilter As String = "", _
Optional ByVal strSqlGroupBy As String = "", Optional ByVal strSqlOrderBy As String = "") As System.Data.DataSet
Dim ds As System.Data.DataSet = Nothing
Try
Me.GetDataAdapter(strSql, strSqlFilter, strSqlGroupBy, strSqlOrderBy)
If Not dataAdapter Is Nothing Then
ds = New System.Data.DataSet
dataAdapter.Fill(ds)
Return ds
Else
Return Nothing
End If
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
Return Nothing
Finally
DisposeDataAdapter(dataAdapter)
End Try
End Function --------------------编程问答-------------------- 有这样写法的吗? 我试试看:select t.* from t_sssx t --------------------编程问答-------------------- 通不过嘛.
select t.* from t_sssx t
应是
select * from t_sssx t --------------------编程问答-------------------- TO: lzmtw
Oracle里select t.* from t_sssx t 是没有问题的哦~ --------------------编程问答-------------------- 哈,我没用过Oracle.
不好意思 --------------------编程问答-------------------- Me.GetDataAdapter(strSql, strSqlFilter, strSqlGroupBy, strSqlOrderBy)
把你这个方法的内容贴出来看看。
提示是你Adapter的SelectCommand的Connection没有初始化。
一般Adapter初始化有两种:
①通过构造函数:
' 通过SQL文和连接对象直接初始化(也可以用连接字符串)
Dim adapter As OracleDataAdapter = New OracleDataAdapter(strSql, objConn)
②通过属性:
Dim adapter As OracleDataAdapter = New OracleDataAdapter()
adapter.SelectCommand = New OracleCommand()
adapter.SelectCommand.Connection = objConn
adapter.SelectCommand.CommandText = strSql
楼主你应该再检查一下你的Adapter构造是否正确。 --------------------编程问答-------------------- 没遇到过这种情况.
补充:.NET技术 , VB.NET