Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SqlCommand cmd = new SqlCommand("select username from registration t1 FULL OUTER JOIN result t2 on t1.username=t2.total where username='" + TextBox1.Text + "' ", con);
          
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataSet ds = new DataSet();
            DataTable dt;
            SqlDataReader dr;
            con.Open();
            dt = ds.Tables["result"];
            dr = cmd.ExecuteReader();
        
            while (dr.Read())
            {
               
                if (TextBox1.Text == dr["total"].ToString())
                {
                    Label2.Text = "select * from result";
                }

            }

now i want to display the result tables value.
what do write..if the question is unclear plz ask me...
Posted
Updated 22-Nov-11 23:36pm
v2
Comments
jim lahey 23-Nov-11 5:38am    
SQL injection just waiting to happen: username='" + TextBox1.Text + "'. Ouch.
Pandya Anil 23-Nov-11 5:46am    
There is not [total] column in Reader, which you selected for comparison !!
Member 8388026 23-Nov-11 6:11am    
Thanks for that.
but the [total] column is in another table.
my requriment is if 6th row of username is value:6,then is should match with only 6th row of total which is in another table,that is my requriment and dispaly it.
can you try once more and tell me plz....

We can't answer that: we have no idea how you want to display the information.
The easiest way is to add a table of some form to your page (A GridView should do) and bind it to the datasource.
But without knowing what you are trying to achieve, we can't really help.

BTW:
Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
C#
SqlCommand cmd = new SqlCommand("select username from registration t1 FULL OUTER JOIN result t2 on t1.username=t2.total where username=@UN", con);
cmd.Parameters.AddWithValue("@UN", TextBox1.Text);
 
Share this answer
 
Actually the results should be bound with any row repeating control like grid, repeater, datalist,
but if your result is returning only one value you can bind it to lable like controls.

bind it like

C#
//bind only 1 row and break loop
Label2.Text = dr["username"].ToString();
break;

//bind multiple rows comma separetted
Label2.Text += dr["username"].ToString() + ",";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900