模仿Duwamish7,却从数据库中无法返回数据,急死人了!!!

outiejun 2003-02-05 12:06:05
模仿Duwamish7的n层结构利用存储过程从数据库中读取数据,却总是返回空的结果.哪位好心人帮帮我,QQ联系24662510,身份验证asp.net,我会把源代码发给您帮我找找错误,您也可以留下QQ,等我在线的时候请教你.

谢谢了,我都快疯了!!!
...全文
44 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
outiejun 2003-02-06
  • 打赏
  • 举报
回复
存储过程已经简化到不能再简单了,还是没有数据返回

CREATE PROCEDURE dbo.GetConfirmedReaders

AS

SELECT *
FROM reader

RETURN 0
GO
outiejun 2003-02-06
  • 打赏
  • 举报
回复
这是common层的readerdata.vb

Option Strict On
Option Explicit On

Imports System
Imports System.Data
Imports System.Runtime.Serialization
Namespace newssystem.common.data

<System.ComponentModel.DesignerCategory("Code"), SerializableAttribute()> Public Class readerdata
Inherits DataSet
Public Const READER_TABLE As String = "reader"
Public Const ID_FIELD As String = "id"
Public Const TITLE_FIELD As String = "title"
Public Const PUBTIME_FIELD As String = "pubtime"
Public Const BODY_FIELD As String = "body"
Public Const IP_FIELD As String = "ip"
Public Const READCOUNT_FIELD As String = "readcount"
Public Const STATE_FIELD As String = "state"
Public Const ANSWER_FIELD As String = "answer"
Public Const AIP_FIELD As String = "aip"
Public Const APUBTIME_FIELD As String = "apubtime"
Public Const AUSERID_FIELD As String = "auserid"

'----------------------------------------------------------------
' Sub New:
' Constructor to support serialization.
'----------------------------------------------------------------

Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
End Sub

'----------------------------------------------------------------
' Sub New:
' Initialize a BookData instance by building the table schema.
'----------------------------------------------------------------
Public Sub New()
MyBase.New()
'
' Create the tables in the dataset
'
BuildDataTables()
End Sub

'----------------------------------------------------------------
' Sub BuildDataTables:
' Creates the following datatables: Reader
'----------------------------------------------------------------
Private Sub BuildDataTables()
'
Dim table As DataTable = New DataTable(READER_TABLE)

With table.Columns
.Add(ID_FIELD, GetType(System.Int32))
.Add(TITLE_FIELD, GetType(System.Int32))
.Add(PUBTIME_FIELD, GetType(System.DateTime))
.Add(BODY_FIELD, GetType(System.String))
.Add(IP_FIELD, GetType(System.String))
.Add(READCOUNT_FIELD, GetType(System.Int32))
.Add(STATE_FIELD, GetType(System.String))
.Add(ANSWER_FIELD, GetType(System.String))
.Add(AIP_FIELD, GetType(System.String))
.Add(APUBTIME_FIELD, GetType(System.DateTime))
.Add(AUSERID_FIELD, GetType(System.String))


End With

Me.Tables.Add(table)
End Sub


End Class

End Namespace
outiejun 2003-02-06
  • 打赏
  • 举报
回复
存储过程肯定没有问题

这是数据访问层的readers.vb

Option Strict On
Option Explicit On
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports newssystem.common
Imports newssystem.common.data
Imports Microsoft.VisualBasic

Namespace newssystem.dataaccess

Public Class readers
Implements IDisposable

Private dscommand As SqlDataAdapter

Public Sub New()

MyBase.new()
dscommand = New SqlDataAdapter()
dscommand.SelectCommand = New SqlCommand()
dscommand.SelectCommand.Connection = New SqlConnection(newssystemconfiguration.getconnectionstring)
dscommand.TableMappings.Add("table", readerdata.READER_TABLE)

End Sub

'----------------------------------------------------------------
' Sub Dispose:
' Dispose of this object's resources.
'----------------------------------------------------------------
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(True) ' as a service to those who might inherit from us
End Sub

'----------------------------------------------------------------
' Sub Dispose:
' Free the instance variables of this object.
'----------------------------------------------------------------
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not disposing Then
Exit Sub ' we're being collected, so let the GC take care of this object
End If

If Not dscommand Is Nothing Then
If Not dscommand.SelectCommand Is Nothing Then
If Not dscommand.SelectCommand.Connection Is Nothing Then
dscommand.SelectCommand.Connection.Dispose()
End If
dscommand.SelectCommand.Dispose()
End If
dscommand.Dispose()
dscommand = Nothing
End If
End Sub



Public Function GetconfirmedreaderData() As readerdata
Dim data As readerdata
data = New readerdata()

With dscommand
Try
With .SelectCommand
.CommandType = CommandType.StoredProcedure ' use stored proc for perf
.CommandText = "GetConfirmedReaders"
End With
.Fill(data)
Finally
If Not .SelectCommand Is Nothing Then
If Not .SelectCommand.Connection Is Nothing Then
.SelectCommand.Connection.Dispose()
End If
.SelectCommand.Dispose()
End If
.Dispose()
End Try
End With

GetconfirmedreaderData = data

End Function

End Class

End Namespace
cattleknife 2003-02-05
  • 打赏
  • 举报
回复
你也是做了四层吧,一层一层测试,最后看一下层与层的接口。
ZHANG9652 2003-02-05
  • 打赏
  • 举报
回复
把sql语句贴出来
saucer 2003-02-05
  • 打赏
  • 举报
回复
add some code to write out the SQL statement to make sure it does return records:

Response.Write("****" + cmd.CommandText+"****");
quicknet 2003-02-05
  • 打赏
  • 举报
回复
同意楼上的观点,可以一层一层测试。先在SQL Server中执行一下存储过程,看看存储过程是否能够正确执行,返回正确的结果,再检查一下数据库的连接字串。

62,039

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧