输入的字符串格式不正确?

编程入门 行业动态 更新时间:2024-10-27 23:21:29
本文介绍了输入的字符串格式不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 执行该代码时出现问题:

Hi every body, I have problem when execute that code:

using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Loging"; cmd.Parameters.AddWithValue("@UserName", username); cmd.Parameters.AddWithValue("@PassWord", password); con.Open(); int x =Convert.ToInt32(cmd.ExecuteScalar()); isAuthenticated = x == 1; }

它给我以下消息: 输入的字符串格式不正确. 它在这部分代码上标记: int x = Convert.ToInt32(cmd.ExecuteScalar()); ?????????

It give me this message: Input string was not in a correct format. It marks on this part of code : int x =Convert.ToInt32(cmd.ExecuteScalar()); ?????????

推荐答案

我愿意是您的cmd返回的内容与int类型不兼容. br/> 存储的proc的返回类型是什么?创建一个变量,首先将结果分配给该变量.然后设置一个断点,看看返回了什么. 干杯. I''d be willing to be that your cmd is returning something that is not compatible with the int type. What is the return type on the stored proc? Create a variable, assign the result to that first. Then set a breakpoint and see what''s returned. Cheers.

更多推荐

输入的字符串格式不正确?

本文发布于:2023-06-04 17:29:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/502166.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   不正确   格式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!