Click here to Skip to main content
11,715,022 members (65,829 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005 C#
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 6:20am
Edited 7-Sep-12 7:03am
Wes Aday at 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 at 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 at 7-Sep-12 12:36pm
how can i solve it?
Wes Aday at 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 at 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 at 7-Sep-12 12:50pm
parameters were not supplied for the function pppp
Ashraff Ali Wahab at 7-Sep-12 14:04pm
Please check you database.You may be having a function which is pppp and also a table pppp.
__TR__ at 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
0 Sergey Alexandrovich Kryukov 520
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320

Advertise | Privacy | Mobile
Web02 | 2.8.150901.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