SqlCeResultSet.ResultSetView Property
Used when data binding a ResultSet to a control.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
Syntax
'Declaration
Public ReadOnly Property ResultSetView As ResultSetView
'Usage
Dim instance As SqlCeResultSet
Dim value As ResultSetView
value = instance.ResultSetView
public ResultSetView ResultSetView { get;
public:
property ResultSetView^ ResultSetView {
ResultSetView^ get ();
/** @property */
public ResultSetView get_ResultSetView ()
public function get ResultSetView () : ResultSetView
Property Value
Example
The following example binds two textbox controls to a ResultSet by using the ResultSetView.
Private conn As SqlCeConnection = Nothing
Private cmd As SqlCeCommand = Nothing
Private rs As SqlCeResultSet = Nothing
Private view As ResultSetView = Nothing
Private textBox1 As TextBox = Nothing
Private textBox2 As TextBox = Nothing
' NOTE: textBox instances are initialized in Form's
' InitializeComponent() which has been omitted for the
' brevity of this code snippet
'
Private Sub onForm_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Me.conn = New SqlCeConnection("Data Source = MyDatabase.sdf")
Me.conn.Open()
Me.cmd = conn.CreateCommand()
Me.cmd.CommandText = "SELECT * FROM Orders WHERE [Order ID] < @orderID"
Me.cmd.Parameters.Add("@orderID", SqlDbType.Int)
End Sub 'onForm_Load
Private Sub buttonBind_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
' Fill the command parameter
'
Me.cmd.Parameters("@orderID").Value = Me.textBox1.Text
' Close the previously data bound result set
'
If Not Nothing Is rs Then
rs.Close()
End If
' Create a new result set instance
'
rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable Or ResultSetOptions.Scrollable)
' ResultSetView implements all data binding interfaces
'
Me.view = rs.ResultSetView
' Bind to text boxes; initially these will display the first row
'
Me.textBox1.DataBindings.Add("text", view, "Order ID")
Me.textBox2.DataBindings.Add("text", view, "Ship Address")
' Note:
' While UI controls are data-bound, the associated
' SqlCeResultSet and SqlCeConnection instances must
' remain open;
'
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub 'buttonBind_Click
' These event handlers are registered on the Next and Previous
' buttons, which control which record is displayed in the data
' bound text boxes;
'
Private Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.BindingContext(Me.view).Position += 1
End Sub 'btnNext_Click
Private Sub btnPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.BindingContext(Me.view).Position -= 1
End Sub 'btnPrev_Click
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
Platforms
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Version Information
.NET Compact Framework
Supported in: 2.0
See Also
Reference
SqlCeResultSet Class
SqlCeResultSet Members
System.Data.SqlServerCe Namespace