Im trying to add in a column entire row into a combobox. When i try it either shows only the last row of the column or it shows only the last row 35 times.
What am i missing? this is driving me crazy. i apologize for the commented lines, i was experimenting with some different coding.
Option Strict On
Imports System.Data.OleDb
Imports ShadowLogin.GlobalVariables
Public Class DeptNewSch
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
ShadowMain.Show()
End Sub
Private Sub DeptNewSch_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim CourseArray(35, 2) As String
Using cnnOLEDB = New OleDbConnection(strConnectionString)
Dim NewSchDS As DataSet
Dim NewSchTables As DataTableCollection
Dim NewSchsource1 As New BindingSource
NewSchDS = New DataSet
NewSchTables = NewSchDS.Tables
Using cmd As New OleDbCommand("SELECT ClassSection.CourseTitle AS Course, ClassSection.SectionNumber AS [Section Number], ClassSection.ScheduleNumber AS [Schedule Number], Course.ShortTitle AS [Course Title], Course.Units, ClassSection.Type AS Format, ClassSection.TimeSlot AS [Days / Time], ClassSection.RoomID AS Location, Faculty.[First Name], Faculty.[Last Name], Classroom.MaxCapacity AS Seats FROM [Classroom], [ClassSection], [Faculty], [Course] WHERE (ClassSection.FRedID = Faculty.FRedID) AND Course.CourseTitle = ClassSection.CourseTitle AND Classroom.RoomID = ClassSection.RoomID AND ClassSection.ScheduleYear=@Year AND ClassSection.Semester=@Semester;", cnnOLEDB)
cmd.Parameters.Add("@Year", OleDbType.VarWChar).Value = Convert.ToInt32(strYear.ToString())
cmd.Parameters.Add("@Semester", OleDbType.VarWChar).Value = strSemester.ToString()
Using NewSchDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
NewSchDA.Fill(NewSchDS, "New Semester") 'Change items to your database name
Dim view As New DataView(NewSchTables(0))
NewSchsource1.DataSource = view
dgNewSch.DataSource = view
Me.dgNewSch.Columns("Course").Width = 60
Me.dgNewSch.Columns("Section Number").Width = 50
Me.dgNewSch.Columns("Schedule Number").Width = 60
Me.dgNewSch.Columns("Course Title").Width = 190
Me.dgNewSch.Columns("Units").Width = 40
Me.dgNewSch.Columns("Format").Width = 70
Me.dgNewSch.Columns("Days / Time").Width = 100
Me.dgNewSch.Columns("Location").Width = 70
Me.dgNewSch.Columns("First Name").Width = 80
Me.dgNewSch.Columns("Last Name").Width = 80
Me.dgNewSch.Columns("Seats").Width = 50
End Using
End Using
End Using
'Connect to Database and get the registration information
Using cnnOLEDB = New OleDbConnection(strConnectionString)
' Query the classschedule table for start of semester datas
Using cmdOleDB = New OleDbCommand("SELECT [CourseTitle], [ShortTitle],[Units] FROM [Course] WHERE rownumber =@row", cnnOLEDB)
cnnOLEDB.Open()
Using rdrOLEDB = cmdOleDB.ExecuteReader
While rdrOLEDB.Read
Dim l As Integer
For l = 0 To 35
'cmdOleDB.Parameters.Add("@row", OleDbType.VarWChar).Value = l
CourseArray(l, 0) = rdrOLEDB.Item(0).ToString
CourseArray(l, 1) = rdrOLEDB.Item(1).ToString
CourseArray(l, 2) = rdrOLEDB.Item(2).ToString
Next
' CboFormat.Items.Add()
' CboDayTime.Items.Add()
' CboLocation.Items.Add()
' CboName.Items.Add()
End While
End Using
End Using
End Using
For z As Integer = 0 To 35
CboCourse.Items.Insert(z, CourseArray(z, 0).ToString)
Next
End Sub
End Class
As you can guess this is the code that ive been working on. Any help would be great if what im trying to do is at all possible.