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 are the media types of http requests and response?

0 Answers  


What is an axd file?

0 Answers  


How do you turn off cookies for one page in your site?

2 Answers   IBS,


What is session handling in a webfarm, how it can work with its limits?

0 Answers   Siebel,


1.can we add connection string in global.asax?????????? 2.what are the default files included when we create new web application????

7 Answers   Sparsh,






What are the new web part controls in asp.net 2.0 ?

0 Answers  


What is .netmodule and how is different from .dll and .exe

2 Answers   NIIT,


What are the different ways you would consider sending data across pages in ASP (i.e between asp to asp)?

0 Answers  


Using code explain Configuration Management

0 Answers  


Which two properties are there on every validation control?

2 Answers  


What is the syntax for datagrid and specifying columns ?

2 Answers   Microsoft,


How to disable validator control by client side JavaScript?

0 Answers  


Categories