Finding the Text value of a column...
-
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)
-
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)
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)
-
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)
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.
-
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.
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)
-
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)