EOF and BOF in .net?

Posted by Maheshvishnu under VB.NET on 10/1/2012 | Points: 10 | Views : 4878 | Status : [Member] | Replies : 2
explain eof&bof with examples?

Thanks in advance,

mahesh


Responses

Posted by: Bageshkumarbagi on: 10/5/2012 [Member] Starter | Points: 25

Up
0
Down
BOF(Before of File)
The BOF property returns True (-1) if the current record position is before the first record in the Recordset, otherwise it returns False (0).
EOF(end of file)
The EOF property returns True (-1) if the current record position is after the last record in the Recordset, otherwise it returns False (0).
Note: The BOF and EOF properties are set to True if you open an empty Recordset. RecordCount property is zero. If a Recordset holds at least one record, the first record is the current and the BOF and EOF properties are False.

SYNTEX
objRecordset.BOF
or
objRecordset.EOF

Example
<%set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
%>

<table border="1" width="100%">
<%while rs.EOF=false%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%wend
rs.close
conn.close
%>



Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh081725 on: 10/9/2012 [Member] Bronze | Points: 25

Up
0
Down
Private Sub Form_Load()
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=system;Persist Security Info=True"
rs.ActiveConnection = con
rs.CursorType = adOpenDynamic
rs.Source = "select * from login"
rs.Open
un = rs.Fields(0).Value
pw = rs.Fields(1).Value
rs.Close


Thanks & Regards,

RAJESH KUMAR.R

End SubIt can be possible with CurrencyManager. Each windows form can have a BindingContext object. It can have number of CurrencyManager objects for each table you are using in the application. By using this it is easy to bind the controls to DB columns and navigations can also be made easy.

Check the folloging code.

Dim cm As CurrencyManager

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
cm.AddNew()
txtNumber.Focus()
End Sub

Private Sub frmDatabase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
DAdapterObj.SelectCommand.CommandText = "select id, name from employee"
DAdapterObj.SelectCommand.Connection = connObj
DAdapterObj.MissingSchemaAction = MissingSchemaAction.AddWithKey
DAdapterObj.Fill(dsObj, "employee")
cm = Me.BindingContext(dsObj.Tables("employee"))
txtNumber.DataBindings.Add("Text", dsObj.Tables("employee"), "id")
txtName.DataBindings.Add("Text", dsObj.Tables("employee"), "name")
cbObj = New MySqlCommandBuilder(DAdapterObj)
dgEmployee.DataSource = dsObj.Tables("employee")
End Sub

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
cm.EndCurrentEdit()
cm.Position = 0
End Sub

Private Sub frmDatabase_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
connObj.Open()
DAdapterObj.Update(dsObj.Tables("employee"))
connObj.Close()
End Sub

Private Sub btnFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFirst.Click
cm.Position = 0
End Sub

Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
If cm.Position > 0 Then
cm.Position -= 1
Else : MsgBox("This is the first record!", MsgBoxStyle.Information)
End If
End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If cm.Position < cm.Count Then
cm.Position += 1
Else : MsgBox("This is the last record!", MsgBoxStyle.Information)
End If
End Sub

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
cm.Position = cm.Count
End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
cm.CancelCurrentEdit()
End Sub

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If cm.Count > 0 Then cm.RemoveAt(cm.Position)
End Sub

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim row As DataRow
row = dsObj.Tables("employee").Rows.Find(txtNumber.Text.Trim)
If row Is Nothing Then
MsgBox("No records found!", MsgBoxStyle.OKOnly)
Else txtName.Text = row.Item(1)
End If
End Sub




Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response