Foros del Web » Programación para mayores de 30 ;) » .NET »

ayudaaaaa!!!

Estas en el tema de ayudaaaaa!!! en el foro de .NET en Foros del Web. hola a todos, pucha necesito saber los codigo, el problema es el siguente, toy haciendo un programa en .net (2003) y queiro que de un ...
  #1 (permalink)  
Antiguo 23/11/2005, 14:02
 
Fecha de Ingreso: noviembre-2005
Mensajes: 1
Antigüedad: 18 años, 5 meses
Puntos: 0
ayudaaaaa!!!

hola a todos, pucha necesito saber los codigo, el problema es el siguente, toy haciendo un programa en .net (2003) y queiro que de un boton aceptar me agrage los datos a la base de datos que tengo conectada (access) y no me acuerdo ya que llevo un año si hacer nada , con suerte me acorde como hacer el boton salir, se le agredece al quien me pueda decir como se hace y ojala sea lo mas explicativo posible .. muchas gracias po tomarme en cuenta chaus

::Maggots::
  #2 (permalink)  
Antiguo 23/11/2005, 20:17
 
Fecha de Ingreso: octubre-2005
Ubicación: Argentina
Mensajes: 15
Antigüedad: 18 años, 6 meses
Puntos: 0
Pregunta

Hola,

En que idioma de programacion ? c# ? vb.net ?

Saludos...
__________________
Gustavo W.
------------------------------
MGB HOSTING ARGENTINA
http://www.mgbhosting.com.ar
  #3 (permalink)  
Antiguo 24/11/2005, 09:13
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 20 años, 11 meses
Puntos: 7
Código:
private objCmd as OleDbCommand
private sub Boton............
       objCmd = OleDbCommand("insert into .....", objCN)
       objCN.Open
       objCmd.ExecuteNonQuery()
       objCN.Close
End Sub
Espero te sirva para orientarte, por cierto, ¿De donde eres Maggots?
__________________
Charlie.
  #4 (permalink)  
Antiguo 24/11/2005, 09:16
Avatar de FNX_NET  
Fecha de Ingreso: marzo-2004
Ubicación: EN EL INFIERNO.....
Mensajes: 1.707
Antigüedad: 20 años, 1 mes
Puntos: 7
para que sepan el estsa trabajando con visual basic .net y esta trabajando con winform, pero le envio esto, para ver si cacha como se hace

Dim fila As DataRow ----> esto crea una nueva fila de datos
OleDbDataAdapter1.Fill(DataTaller2, "Taller") --->con esto le indicas cual es la tabla y cual es el registro virtaul que vas a trabajar osea el data ser

fila = DataTaller2.Tables("Taller").NewRow --> con esto dices que como se tiene que comportar la tabla y cuales son suscolumnas

fila("Rut_Taller") = txtRutTaller.Text con esto dices que la columna rut_taller va obtener el valor del textbox

DataTaller2.Tables("Taller").Rows.Add(fila) y aqui lo mas importante agregas la fila a la base de datos

BindingContext(DataTaller2, "Taller").EndCurrentEdit() con esto confirmas la modificaciones a la base de datos

OleDbDataAdapter1.Update(DataTaller2) con esto actualizar el datasource

Me.Close() y cierrras la conexion
__________________
:-D "Que se libere del cielo confinado; que mi cuerpo sea la espada de hielo negro que nos lleve al abismo; que ningún poder pueda detenernos...Destructora de las almas de los dioses!!!":adios:


:pirata:
  #5 (permalink)  
Antiguo 24/11/2005, 09:47
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Prefiero hacerlo con un objeto Command y un ExecuteNonQuery que con un dataset.. por cuestiones de perfomance.

Por cierto Maggots, antes que nada bienvenido... y ahora que eres nuevo te recomiendo que ese título mas explicitios para que sea mas facil ayudarte.

Saludos
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #6 (permalink)  
Antiguo 24/11/2005, 09:55
 
Fecha de Ingreso: noviembre-2005
Mensajes: 9
Antigüedad: 18 años, 5 meses
Puntos: 0
aqui va un ejemplo

Public Class Form1
Inherits System.Windows.Forms.Form
Private oConexion As SqlConnection
Private oDataSet As DataSet
Private oDataAdapter As SqlDataAdapter

#Region " Código generado por el Diseñador de Windows Forms "

Public Sub New()
MyBase.New()

'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()

'Agregar cualquier inicialización después de la llamada a InitializeComponent()

End Sub

'Form reemplaza a Dispose para limpiar la lista de componentes.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Requerido por el Diseñador de Windows Forms
Private components As System.ComponentModel.IContainer

'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
'Puede modificarse utilizando el Diseñador de Windows Forms.
'No lo modifique con el editor de código.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents btnGrabar As System.Windows.Forms.Button
Friend WithEvents txtIDAutor As System.Windows.Forms.TextBox
Friend WithEvents txtAutor As System.Windows.Forms.TextBox
Friend WithEvents grdDatos As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.txtIDAutor = New System.Windows.Forms.TextBox
Me.txtAutor = New System.Windows.Forms.TextBox
Me.btnGrabar = New System.Windows.Forms.Button
Me.grdDatos = New System.Windows.Forms.DataGrid
CType(Me.grdDatos, System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Label1"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Label2"
'
'txtIDAutor
'
Me.txtIDAutor.Location = New System.Drawing.Point(88, 40)
Me.txtIDAutor.Name = "txtIDAutor"
Me.txtIDAutor.Size = New System.Drawing.Size(112, 20)
Me.txtIDAutor.TabIndex = 2
Me.txtIDAutor.Text = ""
'
'txtAutor
'
Me.txtAutor.Location = New System.Drawing.Point(88, 72)
Me.txtAutor.Name = "txtAutor"
Me.txtAutor.Size = New System.Drawing.Size(112, 20)
Me.txtAutor.TabIndex = 3
Me.txtAutor.Text = ""
'
'btnGrabar
'
Me.btnGrabar.Location = New System.Drawing.Point(264, 32)
Me.btnGrabar.Name = "btnGrabar"
Me.btnGrabar.Size = New System.Drawing.Size(96, 24)
Me.btnGrabar.TabIndex = 4
Me.btnGrabar.Text = "Grabar"
'
'grdDatos
'
Me.grdDatos.DataMember = ""
Me.grdDatos.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.grdDatos.Location = New System.Drawing.Point(32, 120)
Me.grdDatos.Name = "grdDatos"
Me.grdDatos.Size = New System.Drawing.Size(320, 120)
Me.grdDatos.TabIndex = 5
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(392, 281)
Me.Controls.Add(Me.grdDatos)
Me.Controls.Add(Me.btnGrabar)
Me.Controls.Add(Me.txtAutor)
Me.Controls.Add(Me.txtIDAutor)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.grdDatos, System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)

End Sub

#End Region

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

' crear conexión
oConexion = New SqlConnection
oConexion.ConnectionString = "Server=(local);Database=MUSICA;uid=sa;pwd=;"
' crear adaptador
oDataAdapter = New SqlDataAdapter
' crear comandos para inserción, consulta con sus parámetros
' y asignarlos al adaptador
Dim oCmdInsercion As New SqlCommand("INSERT INTO AUTORES " & _
"(IDAutor,Autor) VALUES(@IDAutor,@Autor)", oConexion)
oDataAdapter.InsertCommand = oCmdInsercion
oDataAdapter.InsertCommand.Parameters.Add(New SqlParameter("@IDAutor", SqlDbType.Int))
oDataAdapter.InsertCommand.Parameters.Add(New SqlParameter("@Autor", SqlDbType.NVarChar))
Dim oCmdConsulta As New SqlCommand("SELECT * FROM AUTORES", _
oConexion)
oDataAdapter.SelectCommand = oCmdConsulta
' crear conjunto de datos
oDataSet = New DataSet
Me.CargarDatos()
End Sub
Private Sub CargarDatos()
' vaciar el dataset
oDataSet.Clear()
oConexion.Open() ' abrir conexión
' utilizar el adaptador para llenar el dataset con una tabla
oDataAdapter.Fill(oDataSet, "Autores")
oConexion.Close() ' cerrar conexión
' enlazar dataset con datagrid;
' en DataSource se asigna el dataset,
' en DataMember el nombre de la tabla del
' dataset que mostrará el datagrid
Me.grdDatos.DataSource = oDataSet
Me.grdDatos.DataMember = "Autores"
End Sub

Private Sub btnGrabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrabar.Click
Dim iResultado As Integer
' asignar valores a los parámetros para el
' comando de inserción
oDataAdapter.InsertCommand.Parameters("@IDAutor"). Value = Me.txtIDAutor.Text
oDataAdapter.InsertCommand.Parameters("@Autor").Va lue = Me.txtAutor.Text

' abrir conexión
oConexion.Open()
' ejecutar comando de inserción del adaptador
iResultado = oDataAdapter.InsertCommand.ExecuteNonQuery()
' cerrar conexión
oConexion.Close()
Me.CargarDatos()
MessageBox.Show("Registros añadidos: " & iResultado)
End Sub
End Class
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:54.