输入的字符串格式不正确

输入的字符串格式不正确

本文介绍了输入的字符串格式不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

执行该代码时出现问题:

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());


?????????

推荐答案


这篇关于输入的字符串格式不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 23:24