Click here to Skip to main content
15,903,203 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionMaskedEdit extender and special characters Pin
Peterson Luiz23-Mar-11 5:03
Peterson Luiz23-Mar-11 5:03 
QuestionPaste data from excel Pin
Hum Dum22-Mar-11 23:00
Hum Dum22-Mar-11 23:00 
AnswerRe: Paste data from excel Pin
Dalek Dave23-Mar-11 5:03
professionalDalek Dave23-Mar-11 5:03 
AnswerRe: Paste data from excel Pin
Pavel Yermalovich23-Mar-11 22:47
Pavel Yermalovich23-Mar-11 22:47 
QuestionHow to save data and retrieve data from database using two tables in gridview? Pin
snamyna22-Mar-11 21:55
snamyna22-Mar-11 21:55 
AnswerRe: How to save data and retrieve data from database using two tables in gridview? Pin
ktrrzn5-Apr-11 19:32
ktrrzn5-Apr-11 19:32 
GeneralRe: How to save data and retrieve data from database using two tables in gridview? Pin
snamyna6-Apr-11 14:35
snamyna6-Apr-11 14:35 
AnswerRe: How to save data and retrieve data from database using two tables in gridview? Pin
ktrrzn6-Apr-11 15:12
ktrrzn6-Apr-11 15:12 
hi snamyna,

I think you are looping unnecessarily twice.
Bcoz u already know the loop count of ur career that has Max marks
The only for loop is sufficient, u don't need while loop as usual.
I think, in ur mind, u confuse that SqlDataReader should be loop at the end of file.
it is correct for common. but in ur case, u already know the loop count.

Another problem is u assign the value dr2 to career (same variable) till the end of while loop
without adding to placeholder, after u finish career variable will hold last value of
dr2<br />
so, u end up with last value and when u add to PlaceHolder1 the Label1.Text is last value.
And then u loop again with For loop and start to query again, get the rows and while loop again
loop until to last value and end up with last value, assign it to Label1.Text with exactly the same value(last row).

So, as a suggestion, u juz re-arrange ur coding logic.
Here:

Dim cmdQuery2 As String = "SELECT Career FROM Analysis WHERE Marks= (SELECT MAX(Marks) FROM Analysis ) AND UserID = '" + kp + "'"

Dim cmd2 As SqlCommand = New SqlCommand(cmdQuery2, con)
Dim dr2 As SqlDataReader = cmd2.ExecuteReader()

'con.Open()
For i As Integer = 0 To labelCount - 1 '//** u can also u while loop in here the result will be same
' Create the label control and set its text attribute
Dim Label1 As New Label

 dr2.Read()

career= dr2("Career").ToString()
Label1.Text = career                  '//** u can also directly assign the value from dr2 here

Dim Literal1 As New Literal
Literal1.Text = "<br />"

' Add the control to the placeholder
PlaceHolder1.Controls.Add(Label1)
PlaceHolder1.Controls.Add(Literal1)

Next
dr2.Close()



If u query is right, the problem is the order of ur coding logic.
Hope it works!
GeneralRe: How to save data and retrieve data from database using two tables in gridview? Pin
snamyna6-Apr-11 19:13
snamyna6-Apr-11 19:13 
QuestionHow to Convert ASP.NET web application to ASP.NET Web Service Application Pin
VenkataRamana.Gali22-Mar-11 20:51
VenkataRamana.Gali22-Mar-11 20:51 
QuestionAccess content page procedure from master page button Pin
De_Novice22-Mar-11 6:50
De_Novice22-Mar-11 6:50 
AnswerRe: Access content page procedure from master page button [modified] Pin
Not Active22-Mar-11 7:47
mentorNot Active22-Mar-11 7:47 
GeneralRe: Access content page procedure from master page button Pin
De_Novice22-Mar-11 7:55
De_Novice22-Mar-11 7:55 
GeneralRe: Access content page procedure from master page button Pin
Not Active22-Mar-11 8:02
mentorNot Active22-Mar-11 8:02 
GeneralRe: Access content page procedure from master page button Pin
De_Novice22-Mar-11 8:08
De_Novice22-Mar-11 8:08 
GeneralRe: Access content page procedure from master page button Pin
Not Active22-Mar-11 8:28
mentorNot Active22-Mar-11 8:28 
GeneralOff Topic Pin
Rajesh R Subramanian23-Mar-11 22:06
professionalRajesh R Subramanian23-Mar-11 22:06 
QuestionGive me Suggestions to maintain security for websites Pin
Rajeshwar Code- Developer22-Mar-11 2:27
Rajeshwar Code- Developer22-Mar-11 2:27 
AnswerRe: Give me Suggestions to maintain security for websites Pin
Richard MacCutchan22-Mar-11 4:25
mveRichard MacCutchan22-Mar-11 4:25 
AnswerRe: Give me Suggestions to maintain security for websites Pin
thatraja22-Mar-11 4:49
professionalthatraja22-Mar-11 4:49 
AnswerRe: Give me Suggestions to maintain security for websites Pin
Dalek Dave22-Mar-11 5:06
professionalDalek Dave22-Mar-11 5:06 
JokeRe: Give me Suggestions to maintain security for websites Pin
Not Active22-Mar-11 6:15
mentorNot Active22-Mar-11 6:15 
GeneralRe: Give me Suggestions to maintain security for websites Pin
Paladin200022-Mar-11 6:28
Paladin200022-Mar-11 6:28 
GeneralRe: Give me Suggestions to maintain security for websites Pin
Not Active22-Mar-11 6:47
mentorNot Active22-Mar-11 6:47 
GeneralRe: Give me Suggestions to maintain security for websites Pin
Paladin200022-Mar-11 7:20
Paladin200022-Mar-11 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.