need urgent help about access database and application!!!!!!!!!!  
Author Message
jgon371





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

hey guys i have a question:

i am creating an application in which i am using an access database. I used the wizard to create the connections, data binding, etc. and the drag-and-drop-table method to display it in the form. the problem is that i am not able to (or i have not find a way to update the field of QuantityInStock) update the database. Note that i am only trying to find the code. here is my code:

Public Class Form2

Dim tempInventario As Integer

Dim tempInventarioenBodega As Integer

Private Sub ItemsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Me.Validate()

Me.ItemsBindingSource.EndEdit()

Me.ItemsDA.Update(Me.ItemsDataSet.Items)

End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'TODO: This line of code loads data into the 'ItemsDataSet.Items' table. You can move, or remove it, as needed.

Me.ItemsDA.Fill(Me.ItemsDataSet.Items)

'TODO: This line of code loads data into the 'ItemsDataSet.Items' table. You can move, or remove it, as needed.

Me.ItemsDA.Fill(Me.ItemsDataSet.Items)

End Sub

Private Sub ItemsBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemsBindingNavigatorSaveItem.Click

Me.Validate()

Me.ItemsBindingSource.EndEdit()

Me.ItemsDA.Update(Me.ItemsDataSet.Items)

End Sub

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

If txtInventarioenBodega.Text = "Salir" Or txtInventarioenBodega.Text = "salir" Or txtInventarioenBodega.Text = "SALIR" Then

txtInventarioenBodega.Text = ""

ComboBox1.Focus()

Me.Hide()

Form1.Show()

**************HERE IS WHERE I WANT TO UPDATE THE DATABASE WITH THE CHANGES*************

Else

If IsNumeric(txtInventarioenBodega.Text) Then

If txtInventarioenBodega.Text > -1 Then

tempInventarioenBodega = txtInventarioenBodega.Text

tempInventario = txtInventario.Text

tempInventario = tempInventario + tempInventarioenBodega

txtInventario.Text = tempInventario

txtInventarioenBodega.Clear()

ComboBox1.Focus()

Else

MessageBox.Show("No puede introducir cantidades negativas.")

txtInventarioenBodega.Text = ""

ComboBox1.Focus()

End If

Else

If txtInventarioenBodega.Text = "" Then

MessageBox.Show("Necesita introducir una cantidad o seleccionar otro producto.")

txtInventarioenBodega.Text = ""

ComboBox1.Focus()

Else

MessageBox.Show("Solamente numeros pueden ser procesados.")

txtInventarioenBodega.Text = ""

ComboBox1.Focus()

End If

End If

End If

End Sub

End Class



Visual Studio Express Editions21  
 
 
thedewd





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

Hi jgon,

This line should be at the end of logic. It is what updates (saves) your entry back to the DataBase. You control has to be bound to the the location where you want to save it.

If your Access DataBase is set up properly it should accept UpDates from the TableAdapter. 

After all of your logic is complete and the entry is good, add this line. This will update/save the entry to the DataSet.DataTable and therefore back to the DataBase.

Good Luck.

Me.YourTableAdapter.Update(Me.YourDataSet.YourTable)

 


 
 
spotty





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

If that doesnt help - you may want to chekc that you actually have update/insert/delete methods specified. You can look at the tableadapter properties and there will be Selectcommand, updatecommand, insertcommand and deletecommand properties.

These would also need to be set to propergate chnages back to the database.

If they are not there or to recreate them.

If you right click on the Appropriate TableAdapter on the form or click on the smart tag you will get the option "Edit Queries in Dataset Designer"

This will bring up a diagram of the dataset.

If you select the dataset and use Configure... it allows you to configure the
Select, Insert, Update and Delete statements.

Depending on which ones you select (Example you may want to make the dataset ReadOnly and therefore wouldn't specific the insert/delete or update items).

This will create underlying sql commands which you can see by Right Clicking the TablesAdapter section at the bottom of the dataset and viewing the properties.

This will show such properties as SelectCommand, UpdateCommand, DeleteCommand and InsertCommand depending on how you configured the above.

You can then look at the specific SQL that each of these will run.


 
 
jgon371





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

thank you for your help...i will try it and let you know if it worked....gracias
 
 
jgon371





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

It did not work :-(.... i used the first method (Me.TableAdapter.Update....) and also the second one....Please helpppppppppp i need to finish this application. My main idea is that when i click on Next Product, it checks if the textbox is equal to 'EXIT' if it is then it goes to the main form (me.hide() form1.show()), if not it checks if its numeric, and if it is positive and then it clears the textbox, returns the focus to the combobox1 and finally i want it to update my database. After that in the main form i have a button which launches a query that selects the items from the database that 'StockQty<>Inventory' this program will help us to find variants or differences between the number or quantity that Quickbooks enterprise shows us and what we physically have in stock.
 
 
thedewd





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

It looks like you're using two forms here.

Do you have the variables declared as Public in a Module for Shared Code

It sounds like you need to set up a Module in a separate .vb file and declare Public Variables and a Friend DataSet.

If you search MSDN you can find some tutorials that explain the fundamentals of Data Access, setting up a DataSet, etc. These tutorials will get you off the gound fast.

I'm a beginner myself. The tutorials and the guys here at the forum helped me get my first Access DataBase project finished fast.


 
 
jgon371





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

well i have about 4 forms. the main form which serve as a navigation menu, then we have search/enter inventory by item number, search/enter inventory by BIN Location, and finally we have a report which tells us which items system stock qty is not equal to pysical inventory. the only command that i am missing is updating the database when i close it, and i can only modify one field which is physical inventory. please help!!!!!!!!!!!!!!!!!!
 
 
ReneeC





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

Could I suggest that you read, "How to recieve an optimal answer to your question, at the top of this forum "



 
 
spotty





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

What did not work Did it give you an exception/error or just not save.

Was there an update command in the table adapter property

You need to provide more feedback then "It ddnt work" as that does not provide us with any significant information to assist you further. Remember we cannot see the screen to see what is happening and you need to convey this and any other information to us so we know whats happening.

You want a resolution on the matter then provide us with sufficient details on the problem and what is occuring.


 
 
jgon371





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

thank you anyways...but i found the problem: when visual basic updates the database (in this case access db) it creates a new file inside the bin folder. so everytime you start/run the program you start with your old db. to fix this simply chango from 'copy always' to 'copy if newer' in the solution explorer database properties. thank you all of you for your feedback/anwers. By the way, i am from mexico so maybe my english-communication skills are not very polished.
 
 
dannback





PostPosted: Visual Basic Express Edition, need urgent help about access database and application!!!!!!!!!! Top

Hi!

It costed me few hours to crack this problem, too. Smile

Bye