主题:這問題怎麼解決!VB.NET
Dim cn As New OleDbConnection("Provider=MSDAORA.1;User ID=pos;Data Source=newpos;user id=good;password=good")
Dim ds As New DataSet
Dim dt As DataTable = ds.Tables.Add("breedb")
'Prepare Datatable
Dim cmd As New OleDbCommand("select *from breedb", cn)
'Prepare Command
cn.Open()
Dim rdr As OleDbDataReader = cmd.ExecuteReader
Dim intfirstculumn As Integer = rdr.GetOrdinal("chang_no")
Dim row As DataRow
Do While rdr.Read()
row = dt.NewRow()
row("CHANGE_NO") = rdr(intfirstculumn)
'Fetch data from other columns
dt.Rows.Add(row)
Loop
rdr.Close()
Me.DataGrid1.DataSource = ds.Tables(0)
錯誤提示為“類型System.IndexOutofRangeException”其它信息“Change_no”
Dim ds As New DataSet
Dim dt As DataTable = ds.Tables.Add("breedb")
'Prepare Datatable
Dim cmd As New OleDbCommand("select *from breedb", cn)
'Prepare Command
cn.Open()
Dim rdr As OleDbDataReader = cmd.ExecuteReader
Dim intfirstculumn As Integer = rdr.GetOrdinal("chang_no")
Dim row As DataRow
Do While rdr.Read()
row = dt.NewRow()
row("CHANGE_NO") = rdr(intfirstculumn)
'Fetch data from other columns
dt.Rows.Add(row)
Loop
rdr.Close()
Me.DataGrid1.DataSource = ds.Tables(0)
錯誤提示為“類型System.IndexOutofRangeException”其它信息“Change_no”