Dim major As String = TextBox1.Text
Dim depa As String = TextBox2.Text
Dim sname As String = TextBox3.Text
Dim tbStudent As DataTable
Dim dcPrimaryKey(0) As DataColumn
tbStudent = sqlDataset.Tables("Major")
Dim c As Integer
'selecting the entire rows from dbase
myCommand = New SqlCommand("SELECT count(*) FROM Major", myConnection)
myConnection.Open()
'sqlquery1 = " select count(*) from <tablename>"
' cmd = New SqlCommand(sqlquery1, con)
c = myCommand.ExecuteScalar
Dim drSubject As System.Data.DataRow
drSubject = tbStudent.Rows.Find(major)
If c <> 0 Then
'
myCommand = New SqlCommand("SELECT MajorName,Departement,Suject_Name from Major order by MajorName", myConnection)
Dim dr As SqlDataReader = myCommand.ExecuteReader
'''''check from here
While dr.Read
tbStudent.Rows.Add()
TextBox1.Text = drSubject.Item("MajorName")
TextBox2.Text = drSubject.Item("Departement")
TextBox3.Text = drSubject.Item("Suject_Name")
End While
End If
myConnection.Dispose()
Dili1234
-2
Junior Poster
Recommended Answers
Jump to Postwhat error message message do you get?
Jump to PostFrom looking at your code:
Line 6:
tbStudent = sqlDataset.Tables("Major")
Is sqlDataSet filled with data?
Line 17:
drSubject = tbStudent.Rows.Find(major)
Is your TextBox1 filled?
Line 31 - 33
TextBox1.Text = drSubject.Item("MajorName")
TextBox2.Text = drSubject.Item("Departement")
TextBox3.Text = drSubject.Item("Suject_Name")You pull data from Line 21, and …
Jump to PostIt looks like you are trying to use the same objects for every operation. Try to avoid this since it is back practice and may cause exceptions when two methods are trying to access the same oject at the same time - such as this case. Your data reader (dr) …
All 12 Replies
HibaPro
-3
Junior Poster
Netcode
33
Veteran Poster
Maligui
1
Application Developer
Dili1234
-2
Junior Poster
Dili1234
-2
Junior Poster
Dili1234
-2
Junior Poster
Dili1234
-2
Junior Poster
Maligui
1
Application Developer
Dili1234
-2
Junior Poster
Maligui
1
Application Developer
Dili1234
-2
Junior Poster
Dili1234
-2
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.