Binding Data to Table with Composite ID

Tom Chesley

Member
Joined
Jun 18, 2006
Messages
12
Programming Experience
1-3
I'm still a NEWBEE at VB.NET and using Database's at the same time, so bear with me.

I am Using Visual Studio.NET 2003
the Database is on an SQL Server and I also experimenting with it in MS Access remotely, all I have been having to do was to change the connection so far when remote.

I am currently writing a VB.NET application that is supposed to track Student data from an SQL Database that I created.

I am currently using the GUI to create the Data Connection, and Adapters and Dataset.

The table I am having problems with has a Composite ID (Primary Key)
That table I call tblGrades
The table has the following fields
graStudentID (Primary Key)
graCourseID (Primary Key)
graGrade

The relationship of graStudentID links tblStudents stuStudentID
and graCourseID links to tblCourses couCourseID

The SQL statement I used to set the relationship of these tables don't
seem to bind the data of each of the tables.

I attempted to create a relationship in the data set but I cant select the second table only one or the other.


This application is using textboxs to be bound for the information, not datagrids. All the information I found so far use datagrids for this.

I can provide the application so far if necessary, with the current access database.

I even tried editing the data adapter and created this as a select statement but still cant seem to bind the data from the other tables
to the text boxs
SELECT tblGrades.*, tblStudents.*, tblCourses.*
FROM tblGrades, tblStudents, tblCourses
WHERE graStudentID=stuStudentID And graCourseID=couCourseID

If I use a datagrid the correct information appears in it, but for some reason I cannot bind it to text boxes.
 
Last edited:
More on this binding to text

After playing around for the last week or so, I can now get data bound to the text boxes if i use a VIEW in SQL or a Query in Access, but now any of the related tables wont update. And when I created a data adapter for the new VIEW I got errors on the Update and Delete.
Should I be using the Hard Coding of the adapters and so on like the ADO examples, if so, how would I get to the next record to display?
All the examples I have seen using ADO with hard code seem to be using datagrids.. I dont want that.
 
OK maybe if I say what is wrong with this code?
The courses update but the description doesnt

these table have a relation set in the dataset
ID to ID
the txtboxs are bound to the tables

'update the Courses table
daCourses.Update(dsSeniorProject)
'Find the row in the course description table that the courseid is in
Dim DV As DataView
Dim pos As Integer
DV = New DataView(dsSeniorProject.Tables("tblCourseDesc"))
DV.Sort = ("codCourseID")
pos = DV.Find(txtCourseID.Text)
'if pos = -1 then there is no courseid same in course desc tabe so force id to same and set desc to the desc
If pos = -1 Then
pos = DV.Count
Me.BindingContext(dsSeniorProject, "tblCourseDesc").Position = pos
txtCodCourseID.Text = txtCourseID.Text
txtCodDesc.Text = txtCourseDesc.Text
End If
'update the course desc table
daCourseDesc.Update(dsSeniorProject)
Me.BindingContext(dsSeniorProject, "tblCourses").Position += 1
 
Back
Top