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

晕死了....各位大侠帮忙解决一下吧!!!!!!!!!
Public   Function   getDataTable(ByVal   sql   As   String)   As   DataTable
                Try
                        Dim   sqlAdapter1   As   SqlDataAdapter   =   New   SqlDataAdapter(sql,   cnn)
                        Dim   dataSet   As   DataSet   =   New   DataSet


                        sqlAdapter1.Fill(dataSet)


                        Return   dataSet.Tables(0)
                        sqlAdapter1.Dispose()
                Catch   ex   As   Exception
                        errors.Log(ex.ToString)
                        Return   New   DataTable
                Finally
                        Close()

                End   Try
        End   Function
.................................................
2007-1-9   6:15:54System.NullReferenceException:   未将对象引用设置到对象的实例
      at   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior   cmdBehavior,   RunBehavior   runBehavior,   Boolean   returnStream)
      at   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior   behavior)
      at   System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.FillFromCommand(Object   data,   Int32   startRecord,   Int32   maxRecords,   String   srcTable,   IDbCommand   command,   CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.Fill(DataSet   dataSet,   Int32   startRecord,   Int32   maxRecords,   String   srcTable,   IDbCommand   command,   CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.Fill(DataSet   dataSet)
      at   machine.DBoperate.getDataTable(String   sql)
2007-1-9   16:52:33System.InvalidOperationException:   已有打开的与此连接相关联的   DataReader,必须首先将它关闭。
      at   System.Data.SqlClient.SqlCommand.ValidateCommand(String   method,   Boolean   executing)
      at   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior   cmdBehavior,   RunBehavior   runBehavior,   Boolean   returnStream)
      at   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior   behavior)
      at   System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.FillFromCommand(Object   data,   Int32   startRecord,   Int32   maxRecords,   String   srcTable,   IDbCommand   command,   CommandBehavior   behavior)