私はVB.NETでデータテーブルを作成しようとしていますが、このテーブルから行を出力すると "System.Data.DataRow"と表示されます。VB.NETはデータテーブルを作成しますか?
私のコードをいくつかのウェブサイトと比較したところ、正しいと思われます。しかし、代わりにResponse.Writeこれらの値が正しく表示されます。
Sub Page_Load(Sender as Object, E as EventArgs)
If Not IsPostback Then
...
End If
Main
End Sub
Sub Main()
Dim FirstMonthDate As Date = CDate("1/1/" & dYear.SelectedValue)
Dim LastMonthDate As Date = GlobalFunctions.GlobalF.MonthLastDate(dYear.SelectedValue & "-" & dEndMonth.SelectedValue & "-1")
Dim TheGroup As String
Dim LastWeek As String
Dim FirstWeek As String
Dim dLastWeek As Date
Dim dFirstWeek As Date
Dim iWeek As String
Dim commandstring As String = "SELECT cast(DateDiff(wk, '1/1/2011', '" & LastMonthDate & "') as varchar(30)) AS SELECTED_WEEK "
Dim DSDateData As New System.Data.DataSet
DSDateData = GlobalFunctions.GlobalF.GetDevSQLServerDataSet(commandstring)
Dim dRow As DataRow
For Each dRow In DSDateData.Tables(0).Rows
iWeek = dRow("SELECTED_WEEK")
Next
Dim FirstYearDate As Date = CDate("1/1/" & dYear.SelectedValue)
commandstring = "SELECT DateAdd(ww, " & iWeek & ", '" & FirstYearDate & "') AS LAST_WEEK "
Dim DSDateData2 As New System.Data.DataSet
DSDateData2 = GlobalFunctions.GlobalF.GetDevSQLServerDataSet(commandstring)
For Each dRow In DSDateData2.Tables(0).Rows
LastWeek = dRow("LAST_WEEK")
Next
dLastWeek = CDate(LastWeek)
commandstring = "SELECT DATEADD(dd, -1, DATEADD(wk, DATEDIFF(wk,0, dateadd(dd,6-datepart(day,'" & LastMonthDate & "'),'" & LastMonthDate & "')), 0)) AS FIRST_WEEK "
Dim DSDateData3 As New System.Data.DataSet
DSDateData3 = GlobalFunctions.GlobalF.GetDevSQLServerDataSet(commandstring)
For Each dRow In DSDateData3.Tables(0).Rows
FirstWeek = dRow("FIRST_WEEK")
Next
dFirstWeek = CDate(FirstWeek)
dFirstWeek = DateAdd(DateInterval.WeekOfYear, -1, dFirstWeek)
Dim arrDayYear As New ArrayList()
Dim dFirstDay As New Date
Dim arrList As ArrayList = New ArrayList()
Dim dt2 As New DataTable
Dim sWeek As DataColumn = New DataColumn("sWeek")
sWeek.DataType = System.Type.GetType("System.String")
Dim sDay As DataColumn = New DataColumn("sDay")
sDay.DataType = System.Type.GetType("System.String")
dt2.Columns.Add(sWeek)
dt2.Columns.Add(sDay)
Response.Write("NW1")
Dim dr As DataRow
dr = dt2.NewRow()
dr("sWeek") = "New week"
dr("sDay") = "New day"
dt2.Rows.Add(dr)
Response.Write(dr)
Response.Write("<br>")
dFirstDay = dFirstDay.AddDays(1)
...
End Sub
...
それは "System.Data.DataRow" を引き起こしているこの最後のResponse.Writeです:
は、だからここに私のコードです。しかし、この前のResponse.Write(NW1)は印刷します。だから私は何が間違っているの?
個別に各値と思われます。行全体をどのように印刷するのですか? – user371819
列をルーピングします。 – SLaks