Visual Basic - BindingNavigator is imploding my studio

I guess @PrimeSteak is still busy compiling.

View attachment 1734263
Restored the original database. Slight improvement.

1719999362759.png
I can go through the "pages" now, but it doesn't save to the DB when I enter marks in the text boxes and click the Save icon on the Navigator...

This is the new error I get.
1719999575672.png
My suspicion is, that my changes aren't being saved.

1719999616070.png
This is the code I currently have for the Save button. I think this is the last hurdle I need to cross for this godforsaken project...
 
Restored the original database. Slight improvement.

View attachment 1734685
I can go through the "pages" now, but it doesn't save to the DB when I enter marks in the text boxes and click the Save icon on the Navigator...

This is the new error I get.
View attachment 1734691
My suspicion is, that my changes aren't being saved.

View attachment 1734699
This is the code I currently have for the Save button. I think this is the last hurdle I need to cross for this godforsaken project...
Will have a look in a bit (got my own homework to finish up before the next meetings :X3:), unless someone else wants to check, but I still can't see the object you're actually trying to insert or update.
 
Restored the original database. Slight improvement.

View attachment 1734685
I can go through the "pages" now, but it doesn't save to the DB when I enter marks in the text boxes and click the Save icon on the Navigator...

This is the new error I get.
View attachment 1734691
My suspicion is, that my changes aren't being saved.

View attachment 1734699
This is the code I currently have for the Save button. I think this is the last hurdle I need to cross for this godforsaken project...

Any .commit statements?
 
Stupid question, are you generating a Id before saving or have the model as a Identity or the DB create on insert?
 
Stupid question, are you generating a Id before saving or have the model as a Identity or the DB create on insert?
The IDs are hard-coded into the database, with the marks left open/null. (It's how the DB setup, not by me...)

I guess we have to enter the marks into every record and save them...
 
Will have a look in a bit (got my own homework to finish up before the next meetings :X3:), unless someone else wants to check, but I still can't see the object you're actually trying to insert or update.
1720003862957.png
This is the table I'm trying to write to in Access (don't mind the Table name, I renamed mine proper). We're meant to fill in the exam marks via the project.
 
The IDs are hard-coded into the database, with the marks left open/null. (It's how the DB setup, not by me...)

I guess we have to enter the marks into every record and save them...
Not for new entries. You need to either create them on persistence in code or stipulate the db does it on insertion.

You need to read/research database and data paradigms.
 
View attachment 1734765
This is the table I'm trying to write to in Access (don't mind the Table name, I renamed mine proper). We're meant to fill in the exam marks via the project.
If the entries already exist, you need to probably do a retrieval and update ( if OOP ) or a straight update if possible with the Id as a criteria clause.
 
If the entries already exist, you need to probably do a retrieval and update ( if OOP ) or a straight update if possible with the Id as a criteria clause.
Ok great, but how do I do it via the Navigator's save button?

Because according to the examples in our book, we type whatever into the textboxes (make sure DataBindings is linked to the correct fields in the BindingSource) and we click the Save button in the navigator, and voila, done...
 
Ok great, but how do I do it via the Navigator's save button?

Because according to the examples in our book, we type whatever into the textboxes (make sure DataBindings is linked to the correct fields in the BindingSource) and we click the Save button in the navigator, and voila, done...
How do you load? Because in theory the save should read whatever your object is. Do you create the student number or is there a LOAD first and then a save by selecting a record? When selecting the record, it should have the identifier somewhere and that should be passed on in the save event.

Based on your last error, there was a bigger issue with DBNULL and integer. If ID is a integer it makes no sense unless you have a integer ID and a seperate ID text but then you need to pass the id as I mentioned.
 
How do you load? Because in theory the save should read whatever your object is. Do you create the student number or is there a LOAD first and then a save by selecting a record? When selecting the record, it should have the identifier somewhere and that should be passed on in the save event.
On start-up, the records are loaded into the navigator (which is connected to the BindingSource) (the student IDs being there already as created and all other fields, null).
Based on your last error, there was a bigger issue with DBNULL and integer. If ID is a integer it makes no sense unless you have a integer ID and a seperate ID text but then you need to pass the id as I mentioned.
Student ID is a String I think. All other fields Integers.
 
Private Sub frmGrades_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'StudentsDataSet.Students' table. You can move, or remove it, as needed.
Me.StudentsTableAdapter.Fill(Me.StudentsDataSet.Students)
'TODO: This line of code loads data into the 'GradesDataSet.Grades' table. You can move, or remove it, as needed.
Me.GradesTableAdapter.Fill(Me.GradesDataSet.Grades)

End Sub
@Kosmik

This is what I have specifically in my Load procedure.
 
@Kosmik

This is what I have specifically in my Load procedure.
If I read that right, all thats doing is loading data into two different tables, probably as data sources on form load.

What does your save method look like? and do you have a class declaration for both Grades and Students that you can show?
 
What does your save method look like? and do you have a class declaration for both Grades and Students that you can show?
1720009315801.png

Don't have a class declaration for them, did it all manually with the BindingSource.
 
I'm honestly not sure. There are separate update and insert statements in the adapter

XML:
 <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>UPDATE `Grades` SET `studentID` = ?, `firstExam` = ?, `secondExam` = ?, `finalExam` = ? WHERE ((`studentID` = ?) AND ((? = 1 AND `firstExam` IS NULL) OR (`firstExam` = ?)) AND ((? = 1 AND `secondExam` IS NULL) OR (`secondExam` = ?)) AND ((? = 1 AND `finalExam` IS NULL) OR (`finalExam` = ?)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="studentID" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="studentID" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="firstExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="firstExam" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="secondExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="secondExam" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="finalExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="finalExam" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Original_studentID" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="studentID" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_firstExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="firstExam" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_firstExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="firstExam" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_secondExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="secondExam" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_secondExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="secondExam" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_finalExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="finalExam" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_finalExam" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="finalExam" SourceColumnNullMapping="false" SourceVersion="Original" />
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>

All the fields allow nulls too. You can try change the .Update to .Save maybe but most of this should be handled fine.
 
Top
Sign up to the MyBroadband newsletter
X