Hi,
In my code i want to get values from database based on my textbox value which is greater than that textbox values and display it to another three label
For example in my database
I have fields like,
amount name
1000 bag
2000 watch
3000 mobile
From this if my textbox value is 1000 it will get 2000 and 3000 and display it to two labels respectively.....
Please help.....
Thanks in advance
Loading
Anupam SinghPosted Jun 24, 2014, 8:28 AM
and its no need to use datatable if there are only 2 values.
you can try :
Sagar PardeshiPosted Jun 24, 2014, 12:21 PM
DataTable tbl; cmd.CommandText = "SELECT * FROM YourTable WHERE [user id]='@a'"; cmd.Parameters.AddWithValue("@a", YourTextBox.Text);
dap.SelectCommand = cmd; dap.Fill(tbl);
if( tbl.Rows.Count > 0 ) //user id is already exist
leathu rajPosted Jun 24, 2014, 8:39 AM
leathu rajPosted Jun 24, 2014, 8:11 AM
but i want to get another two value to two labels.
In my example database like if i give 1000 in my textbox one label will display 2000 and another lable will display 3000 if is possible ... or not...
I am in confusion to solve this...
Anupam SinghPosted Jun 24, 2014, 8:01 AM
SqlCommand cmd = new SqlCommand("select gift_points from gift_entry where gift_points >'" + Convert.ToInt32(txt_rewardpoints.Text.Trim()) + "'", con);
By default the value of text box is string type and you might be using int in SQL.
Try this will work.
leathu rajPosted Jun 24, 2014, 7:54 AM
i tried like this..
for next time i give this same coding based on textbox1... But i works and does not get right value..
..
sudipta sanyalPosted Jun 24, 2014, 7:40 AM
Anupam SinghPosted Jun 24, 2014, 7:35 AM