Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/10/2003, 16:17
alejandrom
 
Fecha de Ingreso: septiembre-2003
Mensajes: 41
Antigüedad: 21 años, 4 meses
Puntos: 0
Almacenamiento de un Registro SQL

Estoy Usando SQL Server. En el Formulario tengo 2 Texbox uno llamado Cod y otro Des ademas tengo 2 botones unos de insertar y otro de Grabar.

Inherits System.Windows.Forms.Form
Dim cnx As New SqlClient.SqlConnection("Mi Conection")
Dim daClas As New SqlClient.SqlDataAdapter("SELECT * FROM inClas01", cnx)
Dim dsClas As New DataSet
Dim Table As New DataTable
Dim Pos As Integer

en el FormLoad*******************

cnx.Open()
daClas.Fill(dsClas, "inClas01")
cnx.Close()
Table = dsClas.Tables(0)

Pos = 0
Enlazar()

***************************************

Public Sub Enlazar()

Dim oDataRow As DataRow
oDataRow = Table.Rows(Pos)

Cod.Text = oDataRow("Cod")
Des.Text = oDataRow("Descrip")


End Sub

********************Insertar****************

Private Sub ins_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ins.Click
Dim NewLine As DataRow

NewLine = Table.NewRow
NewLine("Cod") = Cod.Text
NewLine("Descrip") = Des.Text
Table.Rows.Add(NewLine)

End Sub

*****************Grabar*********************

Private Sub gra_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gra.Click

daClas.Update(dsClas,"inClas01")

End Sub

********************************************


Al pulsar el boton de Grabar me da el siguiente error

Additional information: Update requires a valid InsertCommand when passed DataRow collection with new rows.

QUE DEBO HACER POR FAVOR.

si me mandan un ejemplo lo agradeceria

Gracias