Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Finding the Text value of a column...

Finding the Text value of a column...

Scheduled Pinned Locked Moved Visual Basic
helpdatabasequestionworkspace
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CCG3
    wrote on last edited by
    #1

    Hello all, I creating a Temp DataSet and Adapter, populating it and then doing an Insert to move data from this table back into the orginial table I copied it from but with a new DATE. I have it all working fine so far but when I get to trying to list the value of one of my columns (the most inportant one) I can't seem to grab the value. Below is what I have as of now. The line that I am having a problem with is OrderName = ADS.Orders.Select.ToString but I wanted to show you exactly what I am doing. Does anyone have any suggestions? Thank you for any help that you can provide... Dim NewVisitDate As String Dim PriorVisitDate As String Dim SQL As String = String.Empty 'set Variables NewVisitDate = txtVisitDate.Text PriorVisitDate = Me.cbobxPriorDates.Text.ToString MR = frmQuestionnaire.txtMRNo.Text 'create SQL to filter out data SQL = "SELECT OrderMR, OrderDate,Order FROM (Orders) WHERE (OrderMR='" & MR & "') and (OrderDate= #" & PriorVisitDate & "#)" 'create new DataSet and new DataAdapter Dim dr As OleDbDataReader Dim ADS As New AnesDataSet Dim CopyOrders As New OleDbDataAdapter(SQL, Connection) CopyOrders.Fill(ADS, "Orders") 'CopyOrders.Fill(ADS.Orders) Try Connection.Open() Dim Command As New OleDbCommand(SQL, Connection) dr = Command.ExecuteReader() Catch ex As Exception End Try 'run a ForEach statement to modify all of the records in the ADS.Orders table Dim Row As DataRow Dim OrderName As String Dim SQLInsert As String = String.Empty For Each Row In ADS.Orders.Rows OrderName = ADS.Orders.Select.ToString 'setup an SQL to change the Date and Insert new records SQLInsert = "INSERT INTO Orders (OrderMR, OrderDate, [Order]) VALUES (@MR, @NewVisitDate,@OrderName)" Dim Command_Insert As New OleDbCommand(SQLInsert, Connection) Command_Insert.Parameters.AddWithValue("@orderMR", MR) Command_Insert.Parameters.AddWithValue("@OrderDate", NewVisitDate) Command_Insert.Parameters.AddWithValue("@Order", OrderName) Command_Insert.ExecuteNonQuery() 'Console.Write(Command_Insert)

    M 1 Reply Last reply
    0
    • C CCG3

      Hello all, I creating a Temp DataSet and Adapter, populating it and then doing an Insert to move data from this table back into the orginial table I copied it from but with a new DATE. I have it all working fine so far but when I get to trying to list the value of one of my columns (the most inportant one) I can't seem to grab the value. Below is what I have as of now. The line that I am having a problem with is OrderName = ADS.Orders.Select.ToString but I wanted to show you exactly what I am doing. Does anyone have any suggestions? Thank you for any help that you can provide... Dim NewVisitDate As String Dim PriorVisitDate As String Dim SQL As String = String.Empty 'set Variables NewVisitDate = txtVisitDate.Text PriorVisitDate = Me.cbobxPriorDates.Text.ToString MR = frmQuestionnaire.txtMRNo.Text 'create SQL to filter out data SQL = "SELECT OrderMR, OrderDate,Order FROM (Orders) WHERE (OrderMR='" & MR & "') and (OrderDate= #" & PriorVisitDate & "#)" 'create new DataSet and new DataAdapter Dim dr As OleDbDataReader Dim ADS As New AnesDataSet Dim CopyOrders As New OleDbDataAdapter(SQL, Connection) CopyOrders.Fill(ADS, "Orders") 'CopyOrders.Fill(ADS.Orders) Try Connection.Open() Dim Command As New OleDbCommand(SQL, Connection) dr = Command.ExecuteReader() Catch ex As Exception End Try 'run a ForEach statement to modify all of the records in the ADS.Orders table Dim Row As DataRow Dim OrderName As String Dim SQLInsert As String = String.Empty For Each Row In ADS.Orders.Rows OrderName = ADS.Orders.Select.ToString 'setup an SQL to change the Date and Insert new records SQLInsert = "INSERT INTO Orders (OrderMR, OrderDate, [Order]) VALUES (@MR, @NewVisitDate,@OrderName)" Dim Command_Insert As New OleDbCommand(SQLInsert, Connection) Command_Insert.Parameters.AddWithValue("@orderMR", MR) Command_Insert.Parameters.AddWithValue("@OrderDate", NewVisitDate) Command_Insert.Parameters.AddWithValue("@Order", OrderName) Command_Insert.ExecuteNonQuery() 'Console.Write(Command_Insert)

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      Are you attempting to update the date or just add back in all the rows with a new date in addition to the originals? Also, what is the command that is executed at the line OrderName = ADS.Orders.Select.ToString?


      CleaKO

      "Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)

      C 1 Reply Last reply
      0
      • M Marcus J Smith

        Are you attempting to update the date or just add back in all the rows with a new date in addition to the originals? Also, what is the command that is executed at the line OrderName = ADS.Orders.Select.ToString?


        CleaKO

        "Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)

        C Offline
        C Offline
        CCG3
        wrote on last edited by
        #3

        Hey Cleako, thanks for your response. I am writing back the records with a new date in addition to the originals. That line that you noticed is where my problem is. I can't figure out what to set my OrderName variable to. I can't find anything from the intellisense list that will give me the feild value of Orders on the row that I am on.

        M 1 Reply Last reply
        0
        • C CCG3

          Hey Cleako, thanks for your response. I am writing back the records with a new date in addition to the originals. That line that you noticed is where my problem is. I can't figure out what to set my OrderName variable to. I can't find anything from the intellisense list that will give me the feild value of Orders on the row that I am on.

          M Offline
          M Offline
          Marcus J Smith
          wrote on last edited by
          #4

          If you dont have a strongly typed DataSet where the columns are provided then you will need to access the column this way.

          For Each Row In ADS.Orders.Rows

          OrderName = row("Order").ToString

          I hope that helps!


          CleaKO

          "Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)

          C 1 Reply Last reply
          0
          • M Marcus J Smith

            If you dont have a strongly typed DataSet where the columns are provided then you will need to access the column this way.

            For Each Row In ADS.Orders.Rows

            OrderName = row("Order").ToString

            I hope that helps!


            CleaKO

            "Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)

            C Offline
            C Offline
            CCG3
            wrote on last edited by
            #5

            That is EXACTLY what I needed. Thanks CleaKO!!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups