I need some help here...pulling out my hair...
what happens is that I can update, view, edit and search all my records, however, when I want to add a new record, the below executes perfectly, but the record never shows in the database.
Access 97 database
VS2010
here is my code...
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Inventory").NewRow()
With dsNewRow
con.Open()
.Item("DateAdded") = txtDateAdded.Text
.Item("StockNum") = txtStockNum.Text
.Item("SerialNum") = txtSerialNum.Text
.Item("Manufacturer") = txtManufacturer.Text
.Item("Model") = txtModel.Text
.Item("Category") = cmbCategory.Text
.Item("Price") = Convert.ToDouble(Mid(txtPrice.Text, 2, (Len(txtPrice.Text) - 1)))
.Item("Qty") = txtQty.Text
.Item("Status") = cmbStatus.Text
.Item("Description") = txtDescription.Text
.Item("Hours") = Convert.ToInt32(txtHours.Text.Trim())
.Item("Year") = txtYear.Text
.Item("Pictures") = Convert.ToInt32(cmbPictures.Text.Trim())
.Item("HP") = Convert.ToInt32(txtHP.Text.Trim())
.Item("Available") = chkAvailable.Checked
.Item("ForRent") = chkForRent.Checked
.Item("ForSale") = chkForSale.Checked
.Item("Consignment") = chkConsignment.Checked
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Inventory").Rows.Add(dsNewRow)
da.Fill(ds)
ds.AcceptChanges()
da.Update(ds, "Inventory")
con.Close()
MsgBox("New Record added to the Database")
Alos found out if I comment out the "ds.AcceptChanges()"
then I recieve a Syntax error in INSERT INTO statement. on this line - da.Update(ds, "Inventory")
if that helps anyone answer this
what happens is that I can update, view, edit and search all my records, however, when I want to add a new record, the below executes perfectly, but the record never shows in the database.
Access 97 database
VS2010
here is my code...
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Inventory").NewRow()
With dsNewRow
con.Open()
.Item("DateAdded") = txtDateAdded.Text
.Item("StockNum") = txtStockNum.Text
.Item("SerialNum") = txtSerialNum.Text
.Item("Manufacturer") = txtManufacturer.Text
.Item("Model") = txtModel.Text
.Item("Category") = cmbCategory.Text
.Item("Price") = Convert.ToDouble(Mid(txtPrice.Text, 2, (Len(txtPrice.Text) - 1)))
.Item("Qty") = txtQty.Text
.Item("Status") = cmbStatus.Text
.Item("Description") = txtDescription.Text
.Item("Hours") = Convert.ToInt32(txtHours.Text.Trim())
.Item("Year") = txtYear.Text
.Item("Pictures") = Convert.ToInt32(cmbPictures.Text.Trim())
.Item("HP") = Convert.ToInt32(txtHP.Text.Trim())
.Item("Available") = chkAvailable.Checked
.Item("ForRent") = chkForRent.Checked
.Item("ForSale") = chkForSale.Checked
.Item("Consignment") = chkConsignment.Checked
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Inventory").Rows.Add(dsNewRow)
da.Fill(ds)
ds.AcceptChanges()
da.Update(ds, "Inventory")
con.Close()
MsgBox("New Record added to the Database")
Alos found out if I comment out the "ds.AcceptChanges()"
then I recieve a Syntax error in INSERT INTO statement. on this line - da.Update(ds, "Inventory")
if that helps anyone answer this
Last edited: