Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6116693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:08+00:00 2026-05-23T15:14:08+00:00

I am trying to create a datatable in VB.NET, but when I output a

  • 0

I am trying to create a datatable in VB.NET, but when I output a row from this table it shows: “System.Data.DataRow”.

I have compared my code to several websites and it seems correct. However if I instead Response.Write these values they display correctly.

So here is my code:

        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
...

It’s this last Response.Write that is causing the “System.Data.DataRow”. But the Response.Write before this (NW1) does print. So what am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:14:09+00:00Added an answer on May 23, 2026 at 3:14 pm

    Your code is correct.

    Calling Response.Write(dr) prints dr.ToString().
    Since DataRow doesn’t override ToString(), it jsut returns the typename.

    You probably want to prin the value of a column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have C# .NET code with a DataSet (System.Data.DataSet) containing one table of data,
i am trying to create a data table from a tab delimited text file.I
I have created a datatable and trying to insert that datatable through SqlBulkCopy but
I am trying to create a csv file of some data. I have wrote
I am trying to create a flowdocument with a Table of data which I
I am trying to get data from Excel File to DataTable. Here's my code-snippet
I am trying to create a DataTable with a multi row header. I'll exemplify
I'm trying to create a similar functionality to this one: http://www.datatables.net/release-datatables/examples/api/row_details.html . The only
I am trying to create a data table using Jasper reports. I am using
I am trying to create a data table, where I am facing few issues

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.