Mauricio Castillo E

I have an access 2003 db's  but no of the methods of the help index can insert an element to the database.

I've tried with data adapters.

The dataset of the db's try to update but no can do.

help

 

following the code

Dim lect As IDataReader = Me.SistemasDataSet1.CreateDataReader

sistemasDataSet.EstadisticasDataTable.Item(1).Rows.Add("otros")

'sistemasdataset.tables("nombretabla o el indice de la tabla).row(i).colum("importe").tostring() + suma

Me.EstadisticasTableAdapter.Insert("joya", "no ug", "12 / 12 / 2006", "tigre")

other code on other button

 

Dim dt As New DataTable("tblDemo")

Dim coche As DataRow

Dim i As Integer

Dim j As Integer

 

j = j + 1

dt.Columns.Add(New DataColumn("uno"))

dt.Columns.Add(New DataColumn("dos"))

For i = 0 To 15

Dim dr As DataRow()

dr(i) = coche

dr(i + 2) = coche

dt.Rows.Add(dr)

Next

 i've tried each line

 

 




Re: .NET Framework Data Access and Storage Update a access db's with VB express

ahmedilyas

can you post the code you are using and any errors There are MANY examples on these forums to help you get started with inserting into databases, retrieving information and updating the databases. What doesnt work what have you tried




Re: .NET Framework Data Access and Storage Update a access db's with VB express

ahmedilyas

you need to call the Update() method of the table adapter. Be sure that the InsertCommand, UpdateCommand and DeleteCommand have been implemented in the dataset designer view I believe. Usually I think the wizard will ask you if you want to create these or they maybe automatically created. So this should work:

Me.EstadisticasTableAdapter.Update(sistemasDataSet)






Re: .NET Framework Data Access and Storage Update a access db's with VB express

Mauricio Castillo E

Ok.

my database can be update, insert, delete,

but when i run de aplication it cannot make the changtes, i mena if you look the database either open it or put a data grid on your aplication it isnt updated.

ive read on the online help that these methods (update,insert, delete) leave the data on cache,ready to be "write" on the data base.

so am i doing something wrong

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Me.EstadisticasTableAdapter.Insert("carlitos", "coreed", "12 / 26 / 2006", "juan")

End Sub

There are 4 columns on the data base (Remitente,Resumen, fecha,Asesor )

(string,string,date,string)

the primary key is Remitente






Re: .NET Framework Data Access and Storage Update a access db's with VB express

ahmedilyas

sorry I dont follow. Are you saying that the database appears to update but when you look at it the data is not there if so then be sure that if you included the database in the project, to select it in solution explorer and set the copy to output to "never" and initially copy over the database to the project output directory

from the code you posted, you still did not use the Update() command as I had previously stated :-) That command/method is the one that finally commits to the database






Re: .NET Framework Data Access and Storage Update a access db's with VB express

Mauricio Castillo E

Yes, you`re right i posted a wrong code.

Finally the command inserts data but i doesnt update the database, 'cause when i put the code

Me.EstadisticasTableAdapter.Update(sistemasdatset), an error is shown

sistemasdataset cannot be used as an expresion.

so i have to create sistemas dataset as

thanks






Re: .NET Framework Data Access and Storage Update a access db's with VB express

ahmedilyas

be sure that the name of the dataset is correct. if you look at the overloads/parameters for the Update command, the tooltip appears giving you what parameters it expects - so give it the right parameter




Re: .NET Framework Data Access and Storage Update a access db's with VB express

Mauricio Castillo E

Yes, it "worked"

Dim dia As Date

dia = Today

Me.EstadisticasTableAdapter.Insert("carlitos", "coreed", dia, "chaco")

Me.EstadisticasTableAdapter.Update(Me.SistemasDataSet1.Estadisticas)

MsgBox("cambios realizados", MsgBoxStyle.Information)

There is no error, the application runs o.k, it updates the database, but it "erase" all the contens of the database, leaving just a blank database !!!.

These happend when the application run from other computer ( via sql server), so my question is

Do you ahve any example that i can work with or better go on VB 6.0 'cause i did a similar pplication and runs smooth.

Thanks






Re: .NET Framework Data Access and Storage Update a access db's with VB express

PRascal

Hello,

First you have to

Insert...

1.insert with addnew instruction (see in help context)

2. fill in the records data with exp.: mytbale(1) = "my data"

make sure you respect the data type requirement

3. update to record with mytable.update (see in help context)

Change :

1.mytable.edit (see in help context)

then do the changes....

2.update to record with mytable.update (see in help context)

ok, good luck

PASCAL





Re: .NET Framework Data Access and Storage Update a access db's with VB express

Mauricio Castillo E

Yeeeah

 

the following code works perfectly, if you want to see the new data on a data grid, but if you open your access database the changes are not, let`s say ...ummm load or written or update;

Im one step closer to what i want, load that data to the database

Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim connection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\OPERADOR\Mis documentos\bd1.mdb")

' Dim myDataSet As DataSet

'myDataSet = New DataSet()

campo = Today

' Not shown: methods to fill the DataSet with data.

Dim t As DataTable

t = Bd1DataSet.Tables("Consulta")

' Add a DataRow to a table.

Dim myRow As DataRow

myRow = t.NewRow()

myRow("id") = 3

myRow("Nombre") = TextBox2.Text

myRow("Solicitud") = TextBox3.Text

myRow("fecha") = campo

' Add the row.

t.Rows.Add(myRow)

' Calling AcceptChanges on the DataSet causes AcceptChanges to be

'called on all subordinate objects.

Bd1DataSet.AcceptChanges()

Bye






Re: .NET Framework Data Access and Storage Update a access db's with VB express

BonnieB

It's not updating because you still haven't called DataAdapter.Update() method in your above code. The database won't get updated until you do. And be sure that you don't do the DataSet.AcceptChanges() until *after* you do the DataAdapter.Update().