个MySqlException上的ExecuteReader选择用户名(PK) [英] MySqlException on ExecuteReader by Selecting UserID(PK)

查看:140
本文介绍了个MySqlException上的ExecuteReader选择用户名(PK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从数据库中删除行的phpAdmin查询工作
很好,但是当我用



执行它

代码:

 的MySqlCommand getUserID =新的MySqlCommand(选择用户名与用户,连接); 

MySqlDataReader将读卡器= getUserID.ExecuteReader();



我得到的



错误:




目标数组不够长,复制
集合中的所有项目。检查数组索引和长度。




我将之前删除用户没有任何麻烦。



数据库有一个用户名具有属性唯一内部(长9)和自动递增用户名从Char类型。



我的问题是:



为什么我无法收到用户ID ,我怎么能接受呢?



修改



< 。p>我不能接受任何整数或日期数据仅供VARCHAR



下面是创建数据库查询:
Creation查询


解决方案

问题是数据库的MySqlConnection可以'T得到诠释或日期值,如果他们不签名,这也意味着异常:




目标数组不够长复制集合中的所有项目。检查数组索引和长度。



I try to Delete a Row from the Database on the phpAdmin the Query is working fine, but when I execute it with the

Code:

MySqlCommand getUserID = new MySqlCommand("SELECT UserID FROM User", connection);

MySqlDataReader reader = getUserID.ExecuteReader();

I get the

Error:

Destination array is not long enough to copy all the items in the collection. Check array index and length.

I Insert the to deleting user before without any trouble.

The Database has an UserID with properties Unique,Int(Length 9) and Auto-Increment and a UserName from type Char.

My Question is:

Why I can't receive the userID and how can I receive it ?

Edit

I can't receive any integer or date data only varchar.

Here is the Database creation query: Creation Query

解决方案

The Problem is the Database MySqlConnection can´t get Int or Date values if they are not unsigned, that also means the Exception:

"Destination array is not long enough to copy all the items in the collection. Check array index and length."

这篇关于个MySqlException上的ExecuteReader选择用户名(PK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆