这个应用程序我构建了将数据导入数据库并在其上运行一些魔术。然后我想在我的页面上显示单独查询的结果。它现在并没有真正起作用。
应用程序调用:
Dim leftovers As IDataReader
leftovers = GetImportDetails()
Response.Write("<B>Records that were not updated:</B><BR>")
Response.Write(leftovers)
Response.Write("<BR><B>Processing Complete.</B><BR><BR>")
功能:
Function GetImportDetails() As IDataReader
Dim strSQL As String, DAL As New DAL.DataAccess
Dim dr As IDataReader
'Get a list of records that weren't updated
strSQL = "SELECT SalesRep, IDNumber, Name, EffDate, Product, CancDate, Reason " & _
" FROM tblCommCancel"
dr = DAL.ExecDataReader(strSQL, CommandType.Text)
GetImportDetails = dr
dr = Nothing
DAL = Nothing
End Function
现在,我的输出如下:
Records that were not updated:
System.Data.SqlClient.SqlDataReader
Processing Complete.
我在这里缺少什么?
答案 0 :(得分:2)
Response.Write
知道如何处理字符串,但是你传递了IDataReader
。所以它调用.ToString()
的{{1}}函数将它变成一个字符串,这就是为什么你看到&#34; System.Data.SqlClient.SqlDataReader&#34;作为输出。您应该在代码中构建一些HTML并将其写入响应(或将其添加到占位符),或者使用可以将数据绑定到GridView的控件。