Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   .NET (http://www.forosdelweb.com/f29/)
-   -   Almacenamiento de un Registro SQL (http://www.forosdelweb.com/f29/almacenamiento-registro-sql-159646/)

alejandrom 17/10/2003 16:17

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

alejandrom 18/10/2003 10:58

cuando creo todo por codigo es que no me funciona el Update

pero cuando lo hago manualmente osea en diseño colocando el data adapter y el dataset si me funciona el update.

Que me sugieren por favor contesten.

Gracias


La zona horaria es GMT -6. Ahora son las 20:42.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.