Dear Frined my simple update statement is not working on my database software with .mdb

CompanyDa.Update(CompanyDs, "DisplaycenterData")
it works but only in cache, when i restart my application the record is not updated.

i solved my problem with some informal steps. i m attaching vb projects zip file, plz open coding for update button and Help me with simple coding.

yes one important thing i need help and suggestion for is that in that project <Company> and <Book Entry> forms are working nice, but with <purchase5.vb> form i m facing problems, specially i cant update new added data/record, it returns error <Syntax error in INSERT INTO statement.> enven i follwed very same coding patterns and formate as i used in other forms in this project, i tried again and again but faild to solve the problem, i also changed table name and fields in database table but it still not working, and <update> coding of other forms is working nice and <purchase5.vb>'s update coding is not working.
(update coding for company and book entry form is working and it is not working with purchase5 form, plz help to solve the problem)
plz help me with simple coding and removing above mentioned error.

to move between all three forms plz click related button at bottom of each form.

Recommended Answers

All 4 Replies

Try this:
CompanyDa.Update(CompanyDs.table("DisplaycenterData"))
CompanyDs.table("DisplaycenterData").Acceptchanges

No Dear it is not working

here i m sending project again, plz help to Solve error,

I Applied same Code on a dummy form, it worked, but when i tried it on to a Genuine <Purchase> form on which I want to work, it is not updating record, even every code Syntax is same bit by bit, i cant know where i m doing mistake, whether it is in Database file or in Binding Textboxes with Database or with update statement, Because it returns <Syntax error in INSERT INTO statement.> Error Message, plz help me finding error and mistake,
I m Attaching a zip file,
yes its database file is placed inside Project Folder
<\tryitagain\tryitagain\bin\Debug> file name Is tryitagaindata.mdb

and in coding to return Projects' path where database file is placed i used following Code

Pth = My.Application.Info.DirectoryPath

and in Connectin.connectionstring i used <Pth> Variable to Connect with database as follows

Data Source=" & Pth & "\tryitagaindata.mdb; User Id=admin; Password=;"

here in this project Two forms are added based on same Coding, one of them <Form1> is Working but second one <PurchaseOk> is not working, yes both forms are connected with same Database files but separate tables.
Form Form1 is connected with Tblmaster (Table), and Form Purchaseok is Connected with PurchaseTbl (Table)

Plz Find Project Attachment zip file
http://www.daniweb.com/forums/thread274447.html
Help with this problem or to find out mistakes and error plz
Regards and Best Wishes
Fahad

Correction:

1. Change the column name - DateTime to DateTime1 (DateTime is a reserved word)

2.

Private Sub BindDataToControls()
....
 TxtDateTime.DataBindings.Add("text", PurchaseDt, "DateTime1")
....
 txtAmountBalance.DataBindings.Add("Text", PurchaseDt, "AmountBalance")
....
 End Sub

3.

Private Sub FetchDataFromDatabase()
        Try
            PurchaseConn.ConnectionString = "Provider=Microsoft.jet.oledb.4.0; Data Source=" & Pth & "\tryitagaindata.mdb; User Id=admin; Password=;"

            PurchaseSql = "Select * from PurchaseTbl order By PurchaseID"


            PurchaseDa = New OleDbDataAdapter(PurchaseSql, PurchaseConn)
            PurchaseCmb = New OleDbCommandBuilder(PurchaseDa)
            PurchaseDs = New DataSet
            PurchaseDa.Fill(PurchaseDs, "DisplayCenterData")
            PurchaseDt = PurchaseDs.Tables("DisplayCenterData")

           
            DataGridPurchase.DataSource = PurchaseDt

            lblTotalRecords.Text = Me.BindingContext(PurchaseDt).Count
            lblCurrentRecord.Text = Me.BindingContext(PurchaseDt).Position
        Catch ex As Exception

        End Try
    End Sub

Nice code actually. Just two little error made your update not working:
1. the field "DateTime" in your table is a reserved key in VB.NET, change the field name to something else;
2. In your binding control sub, the "totalBalance" should be changed to "AmountBalance".

You will see your beautiful code will work.

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.