How to check the end of the record in Datareader?

Answers were Sorted based on User's Feedback



How to check the end of the record in Datareader?..

Answer / anitha

Dim cmdstr As String
Dim cmdsql As New SqlClient.SqlCommand
Dim consql As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
cmdstr = "select top 1 columnName from tbl_Sample order by
ColumnName desc "
cmdsql = New SqlCommand(cmdstr, consql)
If consql.State = ConnectionState.Closed Then
consql.Open()
Dim drsql As SqlDataReader
drsql = cmdsql.ExecuteReader()
Do While drsql.Read
any Control value= drsql.Item(0)
Loop
drsql.Close()

Is This Answer Correct ?    8 Yes 1 No

How to check the end of the record in Datareader?..

Answer / bhagwat prasad sharma

{vb.net code for selection by data reader}
//\\Start......

imports system.data.sqlclients

public class

dim con as new sqlconnection("server=bps; database=college; user id=sa; password=admin")

private button1 ()

dim str as string="select
name from student where roll_no=1"

dim cmd as new sqlcommand(str,con)

if con.state=connectionstate.closed than
con.open()

cmd.parameters.add("@roll_no",type.int)

cmd.parameters("@roll_no").value=txtroll.text

dim dr as sqldatareader

dr=cmd.executereader

if dr.read than

txtname.text=dr(1)

else

msgbox("selection error ")

end if

con.close()

end sub

end class

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More ASP.NET Interview Questions

What is difference between web config and global asax?

0 Answers  


Where would you use an ihttpmodule, and what are the limitations of any?

0 Answers  


Explain the advantages of passport authentication.

0 Answers  


What is the relationship(in oops) between codebehind and inline code(.aspx to .aspx.cs)??? explain

4 Answers   Mind Tree,


When during the page processing cycle is ViewState available?

1 Answers  


What is custom attribute? How to create?

0 Answers  


Where does the Web page belong in the .NET Framework class hierarchy?

1 Answers  


What does asax stand for?

0 Answers  


What is asp.net and how it works?

0 Answers  


Mention the namespace that is used to include .net data provider for sql server in .net code?

0 Answers  


Define an assembly?

9 Answers   Siebel,


In Data grid the question is below quantity price total these are 3 fields available in data grid if you enter quantity the total has to update automatically.Price field is already filled completely

0 Answers   Quest,


Categories