R
Robert
I'm using the Jet.Oledb to connect to an Access 2002
database. I have a form that is supposed to load
information from the database, and then return
information to it. It loads the info okay, but will not
update the database correctly. I get the error
message: "An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll." The code is as follows:
' conSchoolInfo = data connection
' adpSchoolInfo = data adapter
' "School Info" = table in database and dataset
' txt***.Text = Textboxes on form
Private Sub GetSchoolInfo() ' Subroutine
that runs when the form is loaded
conSchoolInfo.Open()
adpSchoolInfo.Fill(datSchoolInfo, "SchoolInfo")
conSchoolInfo.Close()
txtName.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("Name")
txtCustomerNumber.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("CustomerNo")
txtPostAddress1.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostAddress1")
txtPostAddress2.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostAddress2")
txtPostCity.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostCity")
txtPostState.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostState")
txtPostCountry.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostCountry")
txtPostZip.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostZip")
End Sub
Private Sub SaveSchoolInfo() ' Subroutine
that runs when the form is closed
adpSchoolInfo.Fill(datSchoolInfo, "SchoolInfo")
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("Name") = txtName.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("CustomerNo") = txtCustomerNumber.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostAddress1") = txtPostAddress1.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostAddress2") = txtPostAddress2.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostCity") = txtPostCity.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostState") = txtPostState.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostCountry") = txtPostCountry.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostZip") = txtPostZip.Text
conSchoolInfo.Open()
adpSchoolInfo.Update(datSchoolInfo)
conSchoolInfo.Close()
End Sub
database. I have a form that is supposed to load
information from the database, and then return
information to it. It loads the info okay, but will not
update the database correctly. I get the error
message: "An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll." The code is as follows:
' conSchoolInfo = data connection
' adpSchoolInfo = data adapter
' "School Info" = table in database and dataset
' txt***.Text = Textboxes on form
Private Sub GetSchoolInfo() ' Subroutine
that runs when the form is loaded
conSchoolInfo.Open()
adpSchoolInfo.Fill(datSchoolInfo, "SchoolInfo")
conSchoolInfo.Close()
txtName.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("Name")
txtCustomerNumber.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("CustomerNo")
txtPostAddress1.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostAddress1")
txtPostAddress2.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostAddress2")
txtPostCity.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostCity")
txtPostState.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostState")
txtPostCountry.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostCountry")
txtPostZip.Text = datSchoolInfo.Tables
("SchoolInfo").Rows(0).Item("PostZip")
End Sub
Private Sub SaveSchoolInfo() ' Subroutine
that runs when the form is closed
adpSchoolInfo.Fill(datSchoolInfo, "SchoolInfo")
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("Name") = txtName.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("CustomerNo") = txtCustomerNumber.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostAddress1") = txtPostAddress1.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostAddress2") = txtPostAddress2.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostCity") = txtPostCity.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostState") = txtPostState.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostCountry") = txtPostCountry.Text
datSchoolInfo.Tables("SchoolInfo").Rows(0).Item
("PostZip") = txtPostZip.Text
conSchoolInfo.Open()
adpSchoolInfo.Update(datSchoolInfo)
conSchoolInfo.Close()
End Sub