尝试从表中选择一些记录时,请进入此错误消息。
我的思绪现在正在拍摄.. 有任何想法吗?谢谢!
myreader是,
Public myReader As SqlCeDataReader
Dim currentMatch(1) As String
cmd.CommandText = "SELECT schoolid,opponent " & _
"FROM TEAM_SCHEDULE WHERE seasonid = " & i & _
" AND gameid = " & 1 & " ORDER BY id"
myReader = cmd.ExecuteReader()
Do While myReader.Read()
currentMatch(0) = myReader.GetString(0)
currentMatch(1) = myReader.GetString(1)
Loop
答案 0 :(得分:3)
受过教育的猜测:
schoolid
定义为INT
,但出于某种原因,您使用的是GetString
而不是GetInt32
来获取它。
Do While myReader.Read()
currentMatch(0) = myReader.GetInt32(0).ToString()
currentMatch(1) = myReader.GetString(1)
Loop
答案 1 :(得分:0)
为什么不使用数据表?
Public myReader As SqlCeDataReader
Dim currentMatch(1) As String
cmd.CommandText = "SELECT schoolid,opponent " & _
"FROM TEAM_SCHEDULE WHERE seasonid = " & i & _
" AND gameid = " & 1 & " ORDER BY id"
Dim dt as new DataTable
dt.load(cmd.ExecuteReader())
如果需要,可以使用linq查询结果数据表
dim QueryResults = from p as datarow in dt.rows where p.seasonid<10 select p
或选择一个列表
dim MyObjList = (from p as datarow in dt.rows select seasonid = p.seasonid, gameid = p.gameid).ToList