I was making a vb program that searches a student info by searching a course.. For example Ajax's course is "BSCS" and DP's course is "BSIT" , then i'm going to select BSCS, so Ajax's must only appear not DP. The result appear's in DataGridView
myConnection.Open()
Dim str As String
str = "SELECT * FROM students WHERE (Course = '" & TextBox1.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
dr = cmd.ExecuteReader
While dr.Read()
FirstNameTextBox = dr("FirstName")
MiddleNameTextBox = dr("MiddleName")
LastNameTextBox = dr("LastName")
AddressTextBox = dr("Address")
CellphoneNumberTextBox = dr("CellphoneNumber")
CourseTextBox = dr("Course")
End While
myConnection.Close()
Based on your Code you should add new DataGridView to your form and also adding columns with header name that you choose and replace the code with mine
myConnection.Open()
Dim str As String
str = "SELECT * FROM students WHERE (Course = '" & TextBox1.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
dr = cmd.ExecuteReader
While dr.Read()
DataGridView1.Rows.Add({dr("FirstName"), dr("MiddleName"), dr("LastName"), dr("Address"), dr("CellphoneNumber"), dr("Course")})
End While
myConnection.Close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.