• 0

I want update the data base


Question

I want update the data base ACCESS!

Name: dsl_database.mdb

Table: dsl_tabla

Register: Numero de Control

Numero de Pc Asignada

Address: C:\Documents and Settings\Victor Hugo Garcia\My Documents\dsl

I?ve this code in my application:

Dim linea As Data.DataRow = Me.Dsl_databaseDataSet.dsl_tabla.NewRow()

Dim mydataset As Data.DataSet = Me.Dsl_databaseDataSet()

linea(0) = "5555"

mydataset.Tables(0).Rows.Add(linea)

Me.Dsl_databaseDataSet.dsl_tabla.Rows.Add(linea)

Me.Dsl_tablaTableAdapter.Update(mydataset)

MessageBox.Show("Datos guardados en la base de datos")b>

This part Me.Dsl_tablaTableAdapter.Update(mydataset) b>} generate a mistake on the class:

Public Overloads Overridable Function Update(ByVal dataSet As dsl_databaseDataSet) As Integer Implements Idsl_tablaTableAdapter.Update

Return Me.Adapter.Update(dataSet, "dsl_tabla")

End Function

Public Overloads Overridable Function Update(ByVal dataTable As dsl_databaseDataSet.dsl_tablaDataTable) As Integer Implements Idsl_tablaTableAdapter.Update********** ERROR Return Me.Adapter.Update(dataTable) ************b>

End Function

Public Overloads Overridable Function Update(ByVal dataRows() As System.Data.DataRow) As Integer Implements Idsl_tablaTableAdapter.Update

Return Me.Adapter.Update(dataRows)

End Function

Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As Integer Implements Idsl_tablaTableAdapter.Update

Return Me.Adapter.Update(New System.Data.DataRow() {dataRow})

End Function

This is the message of Visual Basic when mark a ERROR:

<Update requires a valid InsertCommand when passed DataRow collection with new rows.b>

HELP ME!

Please, HELP!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Ah, christ, ACCESS... <rubs eyes>

Sorry. Um... still, I'd think it would still apply that you'd need to insert rows before updating. This isn't ADO, it's ADO.NET.

I think you need to do something along the lines of this:

 cmd = New SqlCommand("INSERT INTO Customers (CustomerID, CompanyName) " &amp; _
                       "VALUES (@CustomerID, @CompanyName)", conn)

  cmd.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID")
  cmd.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName")

Then you could set the values of the parameters by using the Value property. You could also implement the InsertCommand property of the IDBDataAdapter interface like you have with the UpdateCommand.

cmd.Parameters["CustomerID"].Value = 12334
'etc.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.