Can't find column 1 in dataTable that populates dataview then datagrid
-
Why do I get the error can't find column 1.
dtStudList = generalQuery(int) dt.Columns.Add(New DataColumn("Student Name", GetType(String))) 'dt.Columns.Add(New DataColumn("Parent Name", GetType(String))) 'dt.Columns.Add(New DataColumn("Phone", GetType(String))) 'dt.Columns.Add(New DataColumn("Cell", GetType(String))) 'dt.Columns.Add(New DataColumn("Instrument", GetType(String))) For Each row As DataRow In dtStudList.Rows dr = dt.NewRow() dr(0) = row("stud_name") dr(1) = row("stud_par_name") dr(2) = row("stud_id") dr(3) = row("stud_phone") dr(4) = row("stud_cell") ' get student instruments intStudList = Convert.ToInt32(row("stud_id")) tableName = "tbl_lessons" dtStudInst = generalQuery() ' create counter Dim intCount As Integer = 1 For Each row2 As DataRow In dtStudInst.Rows If intCount = 1 Then strInst = Convert.ToString(row2("less_instrument")) Else strInst += ", " & Convert.ToString(row2("less_instrument")) End If Next 'dr(5) = strInst dt.Rows.Add(dr) intCount += 1 Next Dim dgView As New DataView(dt) dgrStudList.DataSource = dgView
-
Why do I get the error can't find column 1.
dtStudList = generalQuery(int) dt.Columns.Add(New DataColumn("Student Name", GetType(String))) 'dt.Columns.Add(New DataColumn("Parent Name", GetType(String))) 'dt.Columns.Add(New DataColumn("Phone", GetType(String))) 'dt.Columns.Add(New DataColumn("Cell", GetType(String))) 'dt.Columns.Add(New DataColumn("Instrument", GetType(String))) For Each row As DataRow In dtStudList.Rows dr = dt.NewRow() dr(0) = row("stud_name") dr(1) = row("stud_par_name") dr(2) = row("stud_id") dr(3) = row("stud_phone") dr(4) = row("stud_cell") ' get student instruments intStudList = Convert.ToInt32(row("stud_id")) tableName = "tbl_lessons" dtStudInst = generalQuery() ' create counter Dim intCount As Integer = 1 For Each row2 As DataRow In dtStudInst.Rows If intCount = 1 Then strInst = Convert.ToString(row2("less_instrument")) Else strInst += ", " & Convert.ToString(row2("less_instrument")) End If Next 'dr(5) = strInst dt.Rows.Add(dr) intCount += 1 Next Dim dgView As New DataView(dt) dgrStudList.DataSource = dgView
AAGTHosting wrote:
Why do I get the error can't find column 1.
On which line does this error show up?? You do know that you commented out a bunch of
Column.Add()
statements near the top of your code snippet, right? Those columns aren't getting created.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
AAGTHosting wrote:
Why do I get the error can't find column 1.
On which line does this error show up?? You do know that you commented out a bunch of
Column.Add()
statements near the top of your code snippet, right? Those columns aren't getting created.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007I know. I just need to know what I am doing wrong with the dataGrid. I commented those lnes out to see if any of the columns would be able to be found.
-
I know. I just need to know what I am doing wrong with the dataGrid. I commented those lnes out to see if any of the columns would be able to be found.
OK. Again, on what line does the error occur??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007