Finding the Text value of a column...

G

Guest

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)
 
G

Guest

Hey, thanks for the response. I did get it working and what I had to use was
close to what you suggested. The line that I had to use was...

OrderName=Row("Order").ToString

But thanks for your reply and your suggestion.


On May 25, 10:31 am, cc_crash <[email protected]>
wrote:
If you have a row defined, then you can just refer to the field name:
OrderName = row("OrderName")
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)
 
Top