个MySqlException上的ExecuteReader选择用户名(PK) [英] MySqlException on ExecuteReader by Selecting UserID(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 propertiesUnique
,Int
(Length 9) andAuto-Increment
and aUserName
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屋!