Click here to Skip to main content
11,925,292 members (63,985 online)
Rate this:
Please Sign up or sign in to vote.
private void btnCalc_Click(object sender, EventArgs e)
           label3.Visible = true;
           label4.Visible = true;
               SqlDataAdapter da = new SqlDataAdapter("select * from pppp where res='" + this.label4.Text+ "'", con);
               DataSet ds = new DataSet();
               da.Fill(ds, "cal");
               DataView vd = new DataView(ds.Tables["cal"]);
               label4.Text = vd[0]["calr"].ToString();
           catch (Exception p)
Posted 7-Sep-12 7:20am
Edited 7-Sep-12 8:03am
Wes Aday 7-Sep-12 12:23pm
Probably, because you are taking a string, converting it to an int, then passing it as a string through your SQL when your id is probably an int.
Ashraff Ali Wahab 7-Sep-12 12:27pm
Please print the exception and post it instead of leaving emplty exception block ,this will solve half your problem.
Gilbertinino 7-Sep-12 12:36pm
how can i solve it?
Wes Aday 7-Sep-12 12:39pm
I know you did not ask me but try: SqlDataAdapter da = new SqlDataAdapter("select * from pppp where id=" + int.Parse(lblId.Text), con);
Ashraff Ali Wahab 7-Sep-12 12:44pm
Gilbertino : What I meant is the exception will show what is the issue with the code.Anyway Wes updated the code ,if it still not works for you ,paste the exception you are getting.
Gilbertinino 7-Sep-12 12:50pm
parameters were not supplied for the function pppp
Ashraff Ali Wahab 7-Sep-12 14:04pm
Please check you database.You may be having a function which is pppp and also a table pppp.
__TR__ 7-Sep-12 12:48pm
This may not have anything to do with the issue you are facing, but i thought will mention it anyway. I noticed that you are first closing the connection and then opening it. This is incorrect. You need to first open the connection to database and once you retrieve the data from database you need to close it at the end.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 7 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100