| |

VerySource

 Forgot password?
 Register
Search
View: 761|Reply: 7

The string was not recognized as a valid Boolean value. Who helped me solve it! ~~ To whom

[Copy link]

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 08:50:01
| Show all posts |Read mode
Exception Details: System.FormatException: The string was not recognized as a valid boolean.

Source error:


Line 57: comm.Parameters ["@ pageCount"]. Direction = ParameterDirection.Output;
Line 58: cnn.Open ();
Line 59: comm.ExecuteNonQuery ();
Line 60: // DataTable dt;
Line 61: //dt=Comm.tools.ConvertDataReaderToDataTable(dr);
 

Source file: d:\web\12\protest.aspx.cs Line: 59

Stack trace:


[FormatException: The string was not recognized as a valid boolean. ]
   System.Data.SqlClient.SqlCommand.ExecuteReader (CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery () +196
   info.protest.CutPageData () in d:\web\12\protest.aspx.cs: 59
   info.protest.Page_Load (Object sender, EventArgs e) in d:\web\12protest.aspx.cs: 28
   System.Web.UI.Control.OnLoad (EventArgs e) +67
   System.Web.UI.Control.LoadRecursive () +35
   System.Web.UI.Page.ProcessRequestMain () +750
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Russia

Post time: 2020-1-6 09:39:01
| Show all posts
Post all the code
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-6 10:12:01
| Show all posts
If the string here is "true" or "false", it may not report an exception!
Reply

Use magic Report

0

Threads

21

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-6 10:54:01
| Show all posts
1\confirm that your .aspx file name is not comm.aspx
2\change comm to _comm try
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-7 13:18:01
| Show all posts
Full code:
SqlConnection cnn = new SqlConnection (ConfigurationSettings.AppSettings ["ConnectionString"]);
SqlCommand _comm = new SqlCommand ("proc_ListPageInt", cnn);
_comm.CommandType = CommandType.StoredProcedure;
SqlDataReader dr = null;
_comm.Parameters.Add ("@ tblName", SqlDbType.NVarChar, 200);
_comm.Parameters ["@ tblName"]. Value = "info_public";
_comm.Parameters.Add ("@ fldName", SqlDbType.NVarChar, 500);
_comm.Parameters ["@ fldName"]. Value = "";
_comm.Parameters.Add ("@ pageSize", SqlDbType.Int);
_comm.Parameters ["@ pageSize"]. Value = 5;
_comm.Parameters.Add ("@ page", SqlDbType.Int);
_comm.Parameters ["@ page"]. Value = 1;
_comm.Parameters.Add ("@ fldSort", SqlDbType.NVarChar, 200);
_comm.Parameters ["@ fldSort"]. Value = "infoid";
_comm.Parameters.Add ("@ Sort", SqlDbType.Bit);
_comm.Parameters ["@ Sort"]. Value = "1";
_comm.Parameters.Add ("@ strCondition", SqlDbType.NVarChar, 1000);
_comm.Parameters ["@ strCondition"]. Value = "";
_comm.Parameters.Add ("@ ID", SqlDbType.NVarChar, 150);
_comm.Parameters ["@ ID"]. Value = "infoid";
_comm.Parameters.Add ("@ Counts", SqlDbType.Int, 0);
_comm.Parameters ["@ Counts"]. Direction = ParameterDirection.Output;
_comm.Parameters.Add ("@ pageCount", SqlDbType.Int, 0);
_comm.Parameters ["@ pageCount"]. Direction = ParameterDirection.Output;
cnn.Open ();
_comm.ExecuteNonQuery ();
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-7 13:36:01
| Show all posts
proc_ListPageInt stored procedure:

http://www.cnblogs.com/hertcloud/archive/2005/12/21/301327.html
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-7 18:18:01
| Show all posts
learning
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-14 09:36:02
| Show all posts
_comm.Parameters.Add ("@ Sort", SqlDbType.Bit);
_comm.Parameters ["@ Sort"]. Value = "1";
==>
_comm.Parameters.Add ("@ Sort", SqlDbType.Bit);
_comm.Parameters ["@ Sort"]. Value = true;
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list