rowe_newsgroups said:
Could you elaborate on what you are trying to accomplish? And could you
post the code you are using? The "normal" (imo) way to do this is to
build a sql command to pull the records from both tables, execute the
command into a dataset or datareader (depending on your needs) and then
do whatever you need to do with the data. Is this what you're doing?
Thanks,
Seth Rowe
Hi Seth,
I was trying to do it without having to do a dataset because I'm still
confused on how to pull the data using DTR connections going from 1st
table to the 2nd and then back to the first...
Below is my code:
Dim stepper, n, filename As String
Dim SW As StreamWriter
Dim FS As FileStream
Dim ST1 As String = "Nothing here."
Dim cmd As System.Data.OleDb.OleDbCommand
Dim cmdstp As System.Data.OleDb.OleDbCommand
Dim DTR As System.Data.oledb.OleDbDataReader
Dim DTRstp As System.Data.oledb.OleDbDataReader 'steps database
reader
n = 1
stepper = "G" & n
cmd = New System.Data.OleDb.OleDbCommand("SELECT Dex, Personal,
Description, Pits, sort, Dates FROM MasterList ORDER BY Sort", cn)
cmdstp = New System.Data.OleDb.OleDbCommand("select " & stepper & "
from Steps", cn)
FS = New FileStream("Export.rtf", FileMode.Append)
SW = New StreamWriter(FS)
DTR = cmd.ExecuteReader()
Dim x As Integer = 0
'Pull data from first table into streamwriter
While DTR.Read()
x += 1
SW.WriteLine("Personal " & x & ": " & (DTR("Personal")) &
vbCrLf & "Date Due: " & (DTR("Dates") & vbCrLf))
'pull in the second table data
DTRstp = cmdstp.ExecuteReader()
While DTRstp.Read
If DTRstp(stepper) Is DBNull.Value Then
SW.WriteLine("No Steps entered" & vbCrLf)
Exit While
End If
ST1 = DTRstp(stepper)
Exit While
Else
SW.WriteLine(ST1 & vbCrLf)
End If
If ST1 = "Nothing entered..." Then
SW.WriteLine(ST1 & vbCrLf)
End If
ST1 = ""
End While
'go back and pull from 1st table
SW.WriteLine(vbTab & "Benefits: " & (DTR("description")) _
& vbCrLf & vbTab & "Pits: " & (DTR("pits")) _
& vbCrLf & vbCrLf)
End While
' Clean-up.
SW.Close()
FS.Close()
System.Diagnostics.Process.Start("export.rtf")
DTR.Close()