I was wondering whether anyone would be so kind as to answer a data question for me or refer me.
I have developed a student program where on a form I have placed 20 text boxes, a dataviewgrid, a navigator etc. I have two databases, one for each school. I need to be able to switch between schools on this student page by selecting the school from the dropdown list.
I was wondering how I can change the bindingsource of this page to connect to schoola or schoolb depending on my selection.
Private Sub RefreshStudentData()
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Dim connString As String = IIf(UCase(sSchoolName) = "SCHOOLA DRIVING SCHOOL", My.Settings.SCHOOLADATAConnectionString, My.Settings.SCHOOLBDATAConnectionString)
Dim sQuery As String = "SELECT [StudentID],[Fullname] FROM [StudentInfo] WHERE [CourseCode]=1 AND INACTIVE=" & IIf(sGroup = "In-Active", True, False) & " ORDER BY [LastName]"
Using connection As New OleDb.OleDbConnection(connString)
Dim command As New OleDb.OleDbCommand(sQuery, connection)
Dim daEmp2 As New OleDb.OleDbDataAdapter(command)
Dim dsEmp As New DataSet
daEmp2.Fill(dsEmp, "StudentInfo")
With DataGridView1
.DataSource = daEmp2
.DataSource = dsEmp.Tables(0)
.AutoGenerateColumns = True
.Columns(0).Width = 60
.Columns(1).Width = 190
.Columns(0).HeaderText = "ID"
.Columns(0).DefaultCellStyle.BackColor = Color.Black
.Columns(0).DefaultCellStyle.ForeColor = Color.White
.Refresh()
End With
System.Windows.Forms.Application.DoEvents()
End Sub
The above fills the dataviewgrid with the selected database but the textboxes and navigator do not talk to the dataviewgrid. Is there an easy fix?
Thanking you in anticipation,
Trevor