|
Dear Mr Richard,
Thanks so much for your reply
I have tried by following your feedback.
I attach my code :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.DatamahasiswaTableAdapter1.Fill(Me.LatihanDataSet.datamahasiswa)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim i As Integer
Dim latihandataset As New latihanDataSet()
Dim datamahasiswatableadapter1 As New latihanDataSetTableAdapters.datamahasiswa1TableAdapter
Try
Me.Validate()
Me.LatihanDataSetBindingSource.EndEdit()
Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text
i = datamahasiswatableadapter1.<big>Update</big>(latihandataset.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Update(LatihanDataSet.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Fill(latihandataset.datamahasiswa)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
End Sub
The result : Update is red underlined in vb.net
Please help me to solving this code, because the updating method has not yet run well.
This is supporting code for grid view, like below
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
TextBox2.Text = Me.LatihanDataSet.Tables(0).Rows(1).Item(0)
TextBox1.Text = Me.LatihanDataSet.Tables(0).Rows(1).Item(1)
End Sub
Thanks so much for your time and attention,
My best regards,
Muljanto
|
|
|
|
|
I do not know what more I can say. I have told you repeatedly what you need to do, and where to find the documents that explain how to do it. It is up to you to configure your system correctly, I cannot do it for you.
|
|
|
|
|
Dear Mr Richard,
I am so sorry for your time and attention.
I have rectified this program, the result is no error bug again, but the update program have not yet updated.
The revised code :
Dim i As Integer
Dim latihandataset As New latihanDataSet()
Dim datamahasiswatableadapter As New latihanDataSetTableAdapters.datamahasiswa1TableAdapter
Try
Me.Validate()
Me.LatihanDataSetBindingSource.EndEdit()
Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text
i = DatamahasiswaTableAdapter1.Update(latihandataset.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Update(latihandataset.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Fill(latihandataset.datamahasiswa)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
I have re-structured the tableadapter to dismiss a bug error...
But the record have not updated successfully......
Please help me for this case.
Thanks so much for your time and attention,
My best regards,
Muljanto
|
|
|
|
|
i want to do a car park booking system in vb, i use picbox to let user click, my questions is, how to link picbox to sql 2014, i means i need to know what picbox user selected, and it will auto record to sql 2014
|
|
|
|
|
Capture the information from the picture box and use that to construct an SQL command. Execute the SQL command to update the database.
|
|
|
|
|
There is no "auto record" function. You give the pictureboxes a name, and save that name in a database when the user clicks it.
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 to display user data after login in vb
|
|
|
|
|
Collect the data, format it into the layout necessary for display and update the window with the new information.
|
|
|
|
|
1. Choose which forum you want to ask your questions in and stick to that forum. In other words, don't post here and in Quick Answers - one or the other!
2.Read the posting guidelines that come up when you click the appropriate link, or are in the tagged message at the top of some forums.
3. Follow the posting guidelines.
You are posting questions without any detail of your problem. We will not just write code for you, but we do want to help you fix your problems. Help us to help you.
|
|
|
|
|
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.
|
|
|
|