
30/10/2010, 17:32
|
| | Fecha de Ingreso: junio-2010
Mensajes: 5
Antigüedad: 14 años, 9 meses Puntos: 0 | |
Problema con Acceso a los Objetos Hola, estoy tratando de realizar un formulario tipo mantenimiento, pero no me da acceso a los objetos BindingSource y los metodos addNew, EndEdit, entre otros, quisiera que me ayudaran urgentemente en esto.
Código:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmSucursales
Public Sub frmSucursales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim cadCon As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BANCOLOMBIA.mdf;Integrated Security=True;User Instance=True"
Dim dsSucursal As New DataSet
Dim daSucural As New SqlDataAdapter("SELECT ID_SUCURSAL, NOMBRE_SUCURSAL, DIR_SUCURSAL, TEL_SUCURSAL FROM SUCURSALES", cadCon)
Dim cbSucursales As New SqlCommandBuilder(daSucural)
daSucural.Fill(dsSucursal, "Sucursales")
Dim bsSucursales As New BindingSource(dsSucursal, "SUCURSALES")
daSucural.InsertCommand = cbSucursales.GetInsertCommand
daSucural.UpdateCommand = cbSucursales.GetUpdateCommand
daSucural.DeleteCommand = cbSucursales.GetDeleteCommand
txt_idsucursal.DataBindings.Add("Text", bsSucursales, "ID_SUCURSAL", True)
txt_nombre_sucursal.DataBindings.Add("Text", bsSucursales, "NOMBRE_SUCURSAL", True)
txt_dir_sucursal.DataBindings.Add("Text", bsSucursales, "DIR_SUCURSAL", True)
txt_tel_sucursal.DataBindings.Add("Text", bsSucursales, "TEL_SUCURSAL", True)
DataGridView1.DataSource = bsSucursales
SUCURSALESBindingNavigator.BindingSource = bsSucursales
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Public Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
End Sub
Private Sub SUCURSALESBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SUCURSALESBindingNavigatorSaveItem.Click
bsSucursales.EndEdit()
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
bsSucursales.AddNew()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class
|