Disconnect a datareader?

  • Thread starter Thread starter mikeb
  • Start date Start date
M

mikeb

Suppose you establish a connection with your sqlce database, use the data
reader to get your data, but then you want to close the connection. Is
there any way to preserve the data written to the data reader??? Example
below:

Private Sub getMyData(byref dr as SqlCeDataReader)
cnSQL.Open()
Sql = "Select * from TestTable where TableID = 32"
Dim cmd as New SqlServerCe.SqlceCommand(sql, cnSQL)
dr = cmd.ExecuteReader()
cnSQL.Close()
End Sub


Private Sub btnTest_Click(...)
Dim dr as SqlCeDataReader

MsgBox getMyData(dr.Item.("myColumn")

End Sub
 
Dang, my last sub was wrong - it should be:

Private Sub btnTest_Click(...)
Dim dr as SqlCeDataReader
getMyData(dr)
MsgBox (dr.Item.("myColumn"))
End Sub

Sorry about that...
 
No, DataReader is a dynamic object. What you are trying to do is achieved by
filling a DataSet with data
 
Back
Top