|
Hola a todos, necesito de su valiosa ayuda para vincular dos DataGridView pero estoy teniendo un problema debido que me muestra el siguiente mensaje justamente en esta parte de codigo y es el siguiente: (El argumento 'column' no puede ser nulo. Nombre del parametro: Column) y no me permite vincularlo, me gustaria que me pudieran ayudar a encontrar el error de antemano muchas gracias
Parte del código donde muestra el mensaje de error
With ds
.Relations.Add("Indice", _
ds.Tables("pa_Listar_Empresa").Columns("db_codigo_empresa"), _
ds.Tables("pa_Listar_Unidad").Columns("db_codigo_empresa"))
End With
Codigo Completo
Imports System.Data
Imports System.Data.SqlClient
Public Class Form_Maestro_Detalle_Procedure
Dim adaptador As New SqlDataAdapter()
Dim ds As New DataSet
Dim cmd As New SqlCommand
Private Sub Form_Maestro_Detalle_Procedure_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CargarDatos()
End Sub
Private Sub Dv_Maestro_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles Dv_Maestro.CellContentClick
Me.lblDetalle.Text = ""
Me.lblDetalle.Text = "Unidades: " & Dv_Detalle.RowCount - 1
End Sub
Public Sub CargarDatos()
Try
conectarse()
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'DataGridView maestro
' ''''''''''''''''''''''''''''''''''''''''''''''''''''
With cmd
' Asignar el sql para seleccionar los datos del objeto Maestro
cmd = New SqlCommand("pa_Listar_Empresa", conn)
cmd.CommandType = CommandType.StoredProcedure
End With
'Enlazamos el procedimiento almacenado y rellenamos el dataset
With adaptador
.SelectCommand = cmd
' llenar el dataset
adaptador.Fill(ds, "pa_Listar_Empresa")
End With
' Enlazar el DataGridView al dataset
With Dv_Maestro
.DataMember = "pa_Listar_Empresa"
.DataSource = ds
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
'.DefaultCellStyle.BackColor = Color.AliceBlue
End With
' ''''''''''''''''''''''''''''''''''''''''''''''''''''
'DataGridView detalles
' ''''''''''''''''''''''''''''''''''''''''''''''''''''
With cmd
' cadena sql para cargar el objeto detalle de ingresos
cmd = New SqlCommand("pa_Listar_Unidad", conn)
cmd.CommandType = CommandType.StoredProcedure
End With
With adaptador
.SelectCommand = cmd
' llenar el dataset
adaptador.Fill(ds, "pa_Listar_Unidad")
End With
With ds
.Relations.Add("Indice", _
ds.Tables("pa_Listar_Empresa").Columns("db_codigo_empresa"), _
ds.Tables("pa_Listar_Unidad").Columns("db_codigo_empresa"))
End With
With Dv_Detalle
Dv_Detalle.DataSource = ds
Dv_Detalle.DataMember = "pa_Listar_Empresa.Indice"
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
'.DefaultCellStyle.BackColor = Color.AliceBlue
End With
lblMaestro.Text = "Empresas: " & ds.Tables("pa_Listar_Empresa").Rows.Count
lblDetalle.Text = "Unidades: " & Dv_Detalle.RowCount - 1
desconectarse()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Los procedimientos almacenados: ambas tablas están vinculados por db_codigo_empresa
ALTER PROCEDURE [dbo].[pa_Listar_Empresa]
AS
SELECT
a.db_codigo_empresa as Codigo,
a.db_razon_social as [Razon Social],
a.db_ruc as Ruc,
a.db_rep_legal as [Representante Legal],
a.db_direccion as Direccion,
a.db_telefono as Telefono,
a.db_correo as Correo,
b.db_denominacion as Actividad,
a.db_estado_empresa as Estado,
FROM tb_Empresa a
INNER JOIN tb_Actividad_Empresa b ON a.db_actividad = b.db_codigo_actividad
WHERE a.db_estado_empresa = 'A'
ORDER BY a.db_razon_social
ALTER PROCEDURE [dbo].[pa_Listar_Unidad]
AS
SELECT
db_codigo as Id,
db_codigo_empresa as Codigo,
db_denominacion as Denominacion,
db_direccion as Direccion,
db_estado_unidad as Estado,
FROM tb_Unidad
WHERE db_estado_unidad = 'A'
|
|
|
|
|
First up, it will be helpful if you can post in English.
The error comes because the columns names you have given are not present in the tables you are using. You will need to verify if the column names you are giving are accurate and also the parent and child tables are in correct order.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
I would like to change Settings->Typing->Change Cursor Thickness to 8 on startup of my application for instance.
Sorry, currently using VB.NET 2.0
Migrating soon to .NET 4.5
|
|
|
|
|
|
I agree on principal. But this application is locked to the forefront, user doesn't have a real mouse or keyboard, so ours is the only application that runs.
|
|
|
|
|
You can change the setting via the registry, but the user will need to sign out and sign in again for that to take effect:
Change Cursor Thickness in Windows 10 | Windows 10 Tutorials[^]
But if you don't own the machine, then don't mess with the user's settings.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: but the user will need to sign out and sign in again for that to take effect:
I think he could just post a WM_SETTINGCHANGE message to the HWND_BROADCAST handle with the wParam set to SPI_SETCURSORS/0x0057 after modifying that registry key.
Best Wishes,
-David Delaune
|
|
|
|
|
So then why are you trying to do this in the app? Just set that up as part of the build process to build (and rebuild) the machine and set it there, where it belongs.
|
|
|
|
|
We use PCs for "Cash Registers" with cash drawer pole display receipt printer what not.
And yeah, we were looking at imaging etc, but it just seemed like far too much effort for our 40 machines.
And I have it in the build instructions to make the change to this and many other settings. But with 10 pages of instructions it gets missed (a management issue), and we kludge in things all the time to prevent the user from fouling things up. So automatically handling it is appealing. But I was review 'notifications' in the area and it looks more complicated. I just want all notification OFF, doesn't appear that is a simple setting in the registry are.
Because these machines will be disconnected from the internet and win 10 hates that. Having the items in code ensures uniformity, whereas with humans. ugh
Thanks for the help, I did find several things and am testing.
|
|
|
|
|
You might glean some further ideas from windows 10 kiosk - Google Search[^]. I have not used this for many versions but it used to basically lock down the machine and run your desired app only.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am developing a program in vb.net to monitor and keep a record of all copied files using the fswatcher class. The program runs well without any bug but gives not output after running.
please help, this is what I have tried.
Imports System.IO
Imports System.Diagnostics
Public Class Form1
Public watchfolder As FileSystemWatcher
Dim watchers As FileSystemWatcher()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_startwatch.Click
watchfolder = New System.IO.FileSystemWatcher()
Dim drives As String() = System.IO.Directory.GetLogicalDrives()
watchers = New FileSystemWatcher(drives.Length - 1) {}
Dim i As Integer = 0
For Each strDrive As String In drives
Dim df As New DriveInfo(strDrive)
If Not df.IsReady Then
Continue For
End If
watchfolder.Path = strDrive
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Attributes
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.CreationTime
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.LastAccess
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Security
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.LastWrite
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Size
AddHandler watchfolder.Changed, AddressOf logchange
AddHandler watchfolder.Created, AddressOf logchange
AddHandler watchfolder.Deleted, AddressOf logchange
AddHandler watchfolder.Renamed, AddressOf logrename
watchfolder.EnableRaisingEvents = True
btn_startwatch.Enabled = False
btn_stop.enabled = True
Next
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
folderactivity.Text &= "file" & e.FullPath & "has been modified" & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Created Then
folderactivity.Text &= "file" & e.FullPath & "has been created" & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
folderactivity.Text &= "file" & e.FullPath & "has been deleted" & vbCrLf
End If
End Sub
Private Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs)
folderactivity.Text &= "file" & e.OldName & "has been renamed to" & e.Name & vbCrLf
End Sub
Private Sub btn_stop_Click(sender As Object, e As EventArgs) Handles btn_stop.Click
watchfolder.EnableRaisingEvents = False
btn_startwatch.Enabled = True
btn_stop.Enabled = False
End Sub
End Class
|
|
|
|
|
You are setting the properties of your watchfolder instance instead those of the watchers list items. So only the last drive is watched.
Solution: Set the properties of your watchers list items and remove the watchfolder . Don't forget to iterate over the list in the stop button handler.
You are setting the path to the drive root but did not specify the FileSystemWatcher.IncludeSubdirectories Property (System.IO)[^]. So you will be only notified about changings in the root directory.
Solution: Set the IncludeSubdir property.
|
|
|
|
|
Thanks for the feedback, am quite new to visual basic so please if you don't mind is there a way you could break down the code more? Please
|
|
|
|
|
Most is already there. Create a list of file system watchers and add the watchers to that list:
Dim watchers As New List(Of FileSystemWatcher)()
Dim watchfolder As New System.IO.FileSystemWatcher()
watchfolder.Path = strDrive
watchers.Add(watchfolder)
For Each watchfolder In watchers
watchfolder.EnableRaisingEvents = False
Next It would be also a good idea to perform the initialisation only once at program start (without enabling the raise of events) and enabling the events in the start button handler (like in the above snippet for stopping).
A final tip:
If you have multiple drives I suggest to exclude the system drive (probably C:\) for testing and change files on the other drives because you will have a lot of notifications for your user directory, the project folder (when building), and the system folders (Windows background activities).
|
|
|
|
|
This is what I have done ,am not sure if it's what you had in mind
Imports System.IO
Imports System.Diagnostics
Public Class Form1
Public watchfolder As FileSystemWatcher
Public watchers As New List(Of FileSystemWatcher)()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_startwatch.Click
Dim drives As String() = System.IO.Directory.GetLogicalDrives()
Dim watchfolder = New System.IO.FileSystemWatcher()
Dim i As Integer = 0
For Each strDrive As String In drives
Dim df As New DriveInfo(strDrive)
If Not df.IsReady Then
Continue For
End If
watchfolder.Path = strDrive
watchers.Add(watchfolder)
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Attributes
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.CreationTime
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.LastAccess
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Security
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.LastWrite
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Size
AddHandler watchfolder.Changed, AddressOf logchange
AddHandler watchfolder.Created, AddressOf logchange
AddHandler watchfolder.Deleted, AddressOf logchange
AddHandler watchfolder.Renamed, AddressOf logrename
watchfolder.EnableRaisingEvents = True
btn_startwatch.Enabled = False
btn_stop.Enabled = True
Next
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
folderactivity.Text &= "file" & e.FullPath & "has been modified" & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Created Then
folderactivity.Text &= "file" & e.FullPath & "has been created" & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
folderactivity.Text &= "file" & e.FullPath & "has been deleted" & vbCrLf
End If
End Sub
Private Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs)
folderactivity.Text &= "file" & e.OldName & "has been renamed to" & e.Name & vbCrLf
End Sub
Private Sub btn_stop_Click(sender As Object, e As EventArgs) Handles btn_stop.Click
For Each watchfolder In watchers
watchfolder.EnableRaisingEvents = False
btn_startwatch.Enabled = True
btn_stop.Enabled = False
Next
End Sub
End Class
|
|
|
|
|
I had nothing in mind. It is your project and you should know what you want to do.
But think about this:
Is it logical to call watchers.Add(watchfolder) first and then set the watchfolder properties?
If you - as a beginner - use existing code as base and want to modify it, it is essential that you understand what the existing code is doing. Then define your requirements (here: multiple watchers) and think about how this can be done (I suggested a list but there are also other solutions like an array).
Also always read the documentation of the used functions and classes. It helps understanding what the function is doing, contains usually example code, and often - most important - notes about what must be considered when using it. Here it is for example (as already noted by Dave):
Quote: The Windows operating system notifies your component of file changes in a buffer created by the T:System.IO.FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer with the P:System.IO.FileSystemWatcher.InternalBufferSize property is expensive, as it comes from non-paged memory that cannot be swapped out to disk, so keep the buffer as small yet large enough to not miss any file change events. To avoid a buffer overflow, use the P:System.IO.FileSystemWatcher.NotifyFilter and P:System.IO.FileSystemWatcher.IncludeSubdirectories properties so you can filter out unwanted change notifications. So watching a complete drive - especially the system drive - will not work as expected.
|
|
|
|
|
This isn't going to work as you expect.
The FSW wasn't really built to watch entire drives. When you get a larger number of changes, like copying thousands of files, it WILL miss files, especially while watching an entire drive.
Read the Remarks section of the FileSystemWatcher documentation[^] for more infomration.
|
|
|
|
|
Is there another way to track files copied to an external drive,(say USB for instance)?
|
|
|
|
|
You actually have no way of knowing that a copy operation is taking place.
A copy operation is nothing but a process opening a file for read and opening another file for write. The process then just reads a block of bytes from one file and writes that block of bytes to the other.
The Last Modified date is updated by the file system on the file being written. Once the operation is finished, the files are closed and the file system updates the Last Modified date on the file written.
That's it, there's nothing special about a file copy. It's no different from an app just writing whatever it needs to to a file on the same disk, say when Notepad saves a file. You can't tell the difference.
All you can tell is that a file was written to the disk. You have no way of knowing why that file was written.
|
|
|
|
|
Do not know if this is applicable but I found this in a search on the internet.
It sounds rather dangerous but perhaps it will help. Search on
Microsoft docs "File System Filter Drivers" which looks like a kernel level driver that may provide
what you want.
From the documentation:
A file system filter driver is an optional driver that adds value to or modifies the behavior of a file system. A file system filter driver is a kernel-mode component that runs as part of the Windows executive.
A file system filter driver can filter I/O operations for one or more file systems or file system volumes. Depending on the nature of the driver, filter can mean log, observe, modify, or even prevent. Typical applications for file system filter drivers include antivirus utilities, encryption programs, and hierarchical storage management systems
Information I found indicates this is not easy to implement. Again, unless you are experienced with
writing kernel-mode drivers (which I am not) this could be a dangerous path.
Other helpers, if I am wrong please correct me so as not to lead him astray.
|
|
|
|
|
It may not apply to "all drives"
No idea which problem is being solved, but if you have to watch all drives, I'll doubt your good intentions.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
How do i count the number of rows from the data grid view and the number of rows to make an integer . The number of rows will be save for preparation.
|
|
|
|
|
|
I suspect that English is not your first language, but this question is very unclear. Please give more information about what you are trying to achieve and we may be able to help you.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
The bigger issue is why are you still using VB6? It's been dead for quite a long time now.
Visual Studio Community Edition is free from here[^] and support VB.NET, C#, C++, ...
|
|
|
|