G
Guest
One record is missing to display in aspx page. But works in SQL query…
When i run a query in MSSQL I get 3 records. but when i run try to display
it in aspx page it displayes only 2 records..
below is the code.. plz help
Public Class hr
Inherits System.Web.UI.Page
Dim MyCommand As SqlCommand
Dim objUserData As Hashtable
Dim MyDataReader As SqlDataReader
Dim MyConnection As SqlConnection
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
MyConnection = New SqlConnection("Persist Security
Info=False;Server=bglamdweb;Database=AMDIndia;User ID=saassword=IEC123")
Dim strSelect As String = "SELECT TOP 6* FROM Amdindia.dbo.Tbl_News WHERE
(News_Dprt_ID=1) ORDER BY News_ID DESC"
MyCommand = New SqlCommand(strSelect, MyConnection)
MyCommand.CommandType = CommandType.Text
MyConnection.Open()
MyDataReader = MyCommand.ExecuteReader()
Dim myGridText As String
If MyDataReader.HasRows Then MyDataReader.Read()
myGridText = "<table width='100%' border='0'>"
Do While MyDataReader.Read
myGridText = myGridText + "<tr><td class='date'>" &
FormatDateTime(MyDataReader("News_Date"), vbShortDate) & "</td></tr>"
myGridText = myGridText + "<tr><td class='news_title'>" &
MyDataReader("News_Title") & "</td></tr>"
myGridText = myGridText + "<tr><td class='news_content'>" &
MyDataReader("News_Detail") & "</td></tr>"
Loop
myGridText = myGridText + "</table>"
myGrid.Text = myGridText
MyDataReader.Close()
MyConnection.Close()
End Sub
End Class
myGrid is a label....
When i run a query in MSSQL I get 3 records. but when i run try to display
it in aspx page it displayes only 2 records..
below is the code.. plz help
Public Class hr
Inherits System.Web.UI.Page
Dim MyCommand As SqlCommand
Dim objUserData As Hashtable
Dim MyDataReader As SqlDataReader
Dim MyConnection As SqlConnection
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
MyConnection = New SqlConnection("Persist Security
Info=False;Server=bglamdweb;Database=AMDIndia;User ID=saassword=IEC123")
Dim strSelect As String = "SELECT TOP 6* FROM Amdindia.dbo.Tbl_News WHERE
(News_Dprt_ID=1) ORDER BY News_ID DESC"
MyCommand = New SqlCommand(strSelect, MyConnection)
MyCommand.CommandType = CommandType.Text
MyConnection.Open()
MyDataReader = MyCommand.ExecuteReader()
Dim myGridText As String
If MyDataReader.HasRows Then MyDataReader.Read()
myGridText = "<table width='100%' border='0'>"
Do While MyDataReader.Read
myGridText = myGridText + "<tr><td class='date'>" &
FormatDateTime(MyDataReader("News_Date"), vbShortDate) & "</td></tr>"
myGridText = myGridText + "<tr><td class='news_title'>" &
MyDataReader("News_Title") & "</td></tr>"
myGridText = myGridText + "<tr><td class='news_content'>" &
MyDataReader("News_Detail") & "</td></tr>"
Loop
myGridText = myGridText + "</table>"
myGrid.Text = myGridText
MyDataReader.Close()
MyConnection.Close()
End Sub
End Class
myGrid is a label....