|
Question : How to seek to particular record in sqlCeResultSet based on a column value
|
|
Hi folks:
I am realatively new to using vb.net and sqlCE. I am trying to seek to a particular record within a sqlCeResultSet, based on the value of one of the columns in the result set. I cannot seem to find an example of the "format" I need to use with the seek command.
Here is the code I am using to create the result set ...
>>>>>>>>>>> CODE <<<<<<<<<
sSQL = "SELECT Files.FileIDX, Files.Name, Files.Extension, Files.Attributes, Files.Size, Files.Created, Files.Modified, Files.Accessed, Files.FolderIDX, Files.ResIDX, " + _ "Files.Selected, Files.Tag1, Files.Offset, Files.DiskVolume, Files.MD5hash, Files.CompressedSize, Files.DeleteFLAG, Files.FXtra1, Files.PreviousVersion, " + _ "Files.Priority, Files.OnSiteVCopiesNum, Files.OffSiteVCopiesNum, Folders.FldrIDX, Folders.FolderSpec, Folders.SelectedFiles, Folders.TotalFiles, " + _ "Folders.DeleteFlag AS Expr1, Folders.xtra1, Folders.ResIDX AS Expr2, Resource.ResIDX AS Expr3, Resource.ResSpec, Resource.ResIDstamp, " + _ "Resource.Network, Resource.Local " + _ "FROM Files INNER JOIN " + _ "Folders ON Files.FolderIDX = Folders.FldrIDX INNER JOIN " + _ "Resource ON Files.ResIDX = Resource.ResIDX " + _ "WHERE(Files.Selected = 1) " + _ "ORDER BY Files.Priority, Files.ResIDX, Files.FolderIDX"
Dim sqlCmd As New SqlCeCommand(sSQL, LogCn) LogFiles_RS = sqlCmd.ExecuteResultSet(ResultSetOptions.Scrollable + ResultSetOptions.Updatable)
>>>>>>>>>>>>> CODE END <<<<<<<<<<<<<
The LogFiles_RS result set is created appropriately, as I have confirmed this in the Server explorer. If I now want to "Seek" a particular record, for example the first record where the value of Files.Name = "ABC", what is the appropriate format? i.e. LogFiles_RS.Seek(DbSeekOptions.FirstEqual, ?????)
Do I need to set other parameters in the sqlCmd ?
Any assistance would be greatly appreciated.
Best regards, Dave Melnyk
|
|
Answer : How to seek to particular record in sqlCeResultSet based on a column value
|
|
SqlCeResultSet Inherits from SqlCeDataReader.
To seek records, you can fill or load a DataTable, set PrimaryKey, then use Find method.
Dim T as new DataTable T.Load(MyDataReader) T.Prymarykey = new DataColumn(){T.Columns("MyKey")} T.Find("Value")
|
|
|
|