Am not a expert programmer, so there will be some mistakes in the way of
coding. So please ignore it and give me an idea for this problem.

On Sat, Mar 21, 2009 at 10:13 PM, Charles A. Lopez
<[email protected]>wrote:

> Ah.. coming from a C background this is where I can lament on the sloppy
> programming practices of writing in visual basic.
>
> On Sat, Mar 21, 2009 at 7:06 AM, Jeena Ajiesh <[email protected]> wrote:
>
>>  Hi paradap,
>> this is the code
>>
>> ---------------------
>> ------------------------
>> total = m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + m10 + m11 + m12
>>
>> percent = total / ct.Text
>>
>
> What is the value of percent at this point break.
>
>>   For Eg: Percent is 90.ct.text is the count of the subject that is
readed above. In some classes the subjects may vary.

>   Dim from, gradeto, name, desc As String
>>
>>
>
> here you are Dim these vars as string. from and gradeto are better off as
> floats.
>  The database is designd using the type varchar for the gradefrom and to.
>


>
>
>
>
>>  Dim con As New SqlConnection(constr)
>>
>> con.Open()
>>
>> Dim cmd As SqlCommand
>>
>> cmd =
>> New SqlCommand("select * from grade where UserName ='" & Session(
>> "CURRENTUSER") & "'and SchoolName='" & lblSchool.Text & "'", con)
>>
>> Dim sdr As SqlDataReader = cmd.ExecuteReader
>>
>> Try
>>
>> While (sdr.Read())
>>
>> from = sdr(
>> "gradefrom")
>>
>> gradeto = sdr(
>> "gradeto")
>>
>> name = sdr(
>> "gradename")
>>
>> desc = sdr(
>> "description")
>>
>> *If (percent >= from) And** (percent <= gradeto*) Then     *//not hitting
>> *
>>
>
>
> here you're comparing a numeric versus a string.
>
The percent and from, gradeto are all in varchar in atasbe and also in code.
If this is the problem i will change and see wat happens.

>    txtgrade.Text = name
>>
>> txtremark.Text = desc
>>
>> 'Exit While
>>
>> End If
>>
>
>
> Here you're saying the while statement ends in the if loop.
>
> THat's like saying ( { ) }. Which mathematically is just plain wrong
> (nested loops).
>
>  While loop will continue as there r rows in database. If the conditionds
> not hits, it will read the next value.I had tried this using breakpoints.
>
>
>>  End While
>>
>> Catch ex As Exception
>>
>> err.Text = ex.Message
>>
>> End Try
>>
>> txttot.Text = total
>>
>> txtpercent.Text = percent
>>
>> 'txtgrade.Text = gradename
>>
>> 'txtremark.Text = remark
>>
>> Dim username, schoolname, sname, sid, clas, ename As String
>>
>> username = lblusername.Text
>>
>> schoolname = lblSchool.Text
>>
>> sname = txtsname.Text
>>
>> clas = ddlclass.SelectedItem.Text
>>
>> sid = txtid.Text
>>
>> ename = ddlexamname.SelectedItem.Text
>>
>>
>>
>> hope this is enough....
>>
>> Thanks in Advance
>>
>>
>>   On Wed, Mar 18, 2009 at 7:13 PM, Pradap A <[email protected]>wrote:
>>
>>> hi jeena,
>>>
>>> can you give me the expand of your code . then only i will give the
>>> solution perfectly . thanks
>>>
>>> regards
>>> A.Paradap
>>>
>>>
>>>
>>> On Wed, Mar 18, 2009 at 7:11 PM, Jeena Ajiesh <[email protected]>wrote:
>>>
>>>>  Hi all,
>>>> this may be a small error,
>>>> anyway the problem is even though the condition is true, its not
>>>> hitting.
>>>> I'm retrieving some values from database and storing it in variable.
>>>> Along with that,I'm comparing the retrieved value with another variable.
>>>> Even if its true, its not going inside if loop.
>>>> Can anyone find out that small error.
>>>>
>>>> My Code is as follows
>>>>
>>>> while sdr.Read()
>>>>     from=sdr(0)
>>>>     to=sdr(1)
>>>>     name=sdr(2)
>>>>     desc=sdr(3)
>>>>       if (percent>=from) And (percent<=to)
>>>>          txtname.text=name          //These r not executed.....
>>>>          txtdesc.text=desc
>>>>       End If
>>>> End While
>>>> Im doing it in Asp.net,vs2005
>>>> --
>>>> ****************
>>>> Regards,
>>>> ♪♥♫♥Ĵєєήǎ ♫♥♪♥
>>>> Email: [email protected]
>>>>          [email protected]
>>>>          [email protected]
>>>>
>>>>
>>>
>>
>>
>> --
>> ****************
>> Regards,
>> ♪♥♫♥Ĵєєήǎ ♫♥♪♥
>> Email: [email protected]
>>          [email protected]
>>          [email protected]
>>
>> Sent from: Dubayy  United Arab Emirates.
>>
>
>
>
> --
> Charles A. Lopez
> [email protected]
>
> Bachelor of Arts - Computer Science
> New York University
>
> Registered Microsoft Partner
>
> New York City, NY
>



-- 
****************
Regards,
♪♥♫♥Ĵєєήǎ ♫♥♪♥
Email: [email protected]
         [email protected]
         [email protected]

Sent from: Dubayy  United Arab Emirates.

Reply via email to