|
There is no alternative to filecopy that returns the percentage of files copied during the copy, since opening the file in binary mode is not necessary because the put and get commands are probably due to an overflow since I operate on 2GB files up.
|
|
|
|
|
There is no alternative built into VB6.
You're either going to have to code up your own version in something else that can be exposed to COM and handle 64-bit offsets, like in C#/VB.NET/C/C++, or just have the Shell copy files for you. In that case, you'll end up with the Explorer progress window, just as if you dragged and dropped a file to copy by hand.
|
|
|
|
|
And how do you make a copy with the shell, what command you have to run, and then shows the progress bar with the percentage of files copied?
|
|
|
|
|
|
Thanks a lot even though it was better if I did it with my PROGRess bar and with the instruct put and get opening it in binary....
|
|
|
|
|
You simply don't have that option in your own code because VB6 is 32-bit only and the largest integer it can handle is 2,147,483,647. That makes offsets into a file a max of 2.147GB.
|
|
|
|
|
I writ in italian(with percentage):
private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret As Long
'set the graphics mode to persistent
Me.AutoRedraw = True
'print some text
Me.Print "Click the form to abort the filecopy"
'show the form
Me.Show
'start copying
Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
'show some text
Me.Print "Filecopy completed " + IIf(Ret = 0, "(ERROR/ABORTED)", "successfully")
End Sub
Private Sub Form_Click()
'cancel filecopy
bCancel = 1
End Sub
'in a module
Public Const PROGRESS_CANCEL = 1
Public Const PROGRESS_CONTINUE = 0
Public Const PROGRESS_QUIET = 3
Public Const PROGRESS_STOP = 2
Public Const COPY_FILE_FAIL_IF_EXISTS = &H1
Public Const COPY_FILE_RESTARTABLE = &H2
Public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long
Public bCancel As Long
Public Function CopyProgressRoutine(ByVal TotalFileSize As Currency, ByVal TotalBytesTransferred As Currency, ByVal StreamSize As Currency, ByVal StreamBytesTransferred As Currency, ByVal dwStreamNumber As Long, ByVal dwCallbackReason As Long, ByVal hSourceFile As Long, ByVal hDestinationFile As Long, ByVal lpData As Long) As Long
'adjust the caption
Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
'allow user input
DoEvents
'continue filecopy
CopyProgressRoutine = PROGRESS_CONTINUE
End Function
Trovato qui(restituisce pure la percentuale) https://www.experts-exchange.com/questions/20743248/Problem-Writing-Reading-a-File-2GB-HELP.html
testato con 10 gb di piu' fatelo voi ma dovrebbe funzionare,mi fido!!!!
|
|
|
|
|
Dear All,
Please help me in providing this solution.
I have just learned Microsoft Visual Basic. Net 2015 with SQL Server 2014.
One problem in update command method, I have prepared the program like this :
Dim i As Integer
Dim update1 As String = ("update datamahasiswa set no= ’" & TextBox1.Text & "’ where nama= ’" & TextBox2.Text & "’")
Try
Me.Validate()
Me.LatihanDataSetBindingSource.EndEdit()
Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text
i = DatamahasiswaTableAdapter1.Update(LatihanDataSet.datamahasiswa)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
The message shown up, like this :
update requires a valid update command when passed data row collection with modified rows. It means : the update method does not run well.
When I insert the command Executequery, this is not enlisted in VB.net
Please help me,
Thank you for your time and attention,
My best regards,
Muljanto
modified 6-Aug-18 7:45am.
|
|
|
|
|
Don't use string concatenation to generate SQL commands. Apart from leaving you wide open to SQL Injection Attacks[^], you can introduce other errors.
Use Parameterized queries instead: see Query Parameterization Cheat Sheet - OWASP[^]
So you would have some code like this
Dim update1 As String = ("update datamahasiswa set no= @parm1 where nama=@parm2") and then some code to add the parameters.
Note I have not included the single quotes ( ' ) in the sql to surround the variable name. You have actually used a ’ character - which is not the same as ' . Using parameterised queries removes errors like that.
|
|
|
|
|
You have not connected your update1 string to your table adapter. So your call to DatamahasiswaTableAdapter1.Update has nothing to work from.
|
|
|
|
|
Dear Mr Richard,
Please tell me how to connect the update command method with update1.
Dim i As Integer
Dim update1 As String = (“update datamahasiswa set no= & TextBox1.Text & where nama= &
TextBox2.Text & ”)
Try
Me.Validate()
Me.LatihanDataSetBindingSource.EndEdit()
Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text
i = DatamahasiswaTableAdapter1.Update(LatihanDataSet.datamahasiswa)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
The message : this needs valid update command
I propose this question, because it has not yet solved my problem.
Thank you for your time and attention,
My best regards,
Muljanto
|
|
|
|
|
|
Member 12813074 wrote: (“update datamahasiswa set no= & TextBox1.Text & where nama= & TextBox2.Text & ”)
You also seem to be failing String Handling 101.
That code will NOT put the value in TextBox1 into the string. Your actual SQL query will read like this every single time you execute it no matter what you type into the TextBoxes:
"update datamahasiswa set no= & TextBox1.Text & where nama= & TextBox2.Text & "
Again, it will NOT place the values of TextBox1.Text and TextBox2.Text into the SQL string you're building.
You might want to read up on this & Operator (Visual Basic) | Microsoft Docs[^].
Also, NEVER build SQL strings like this. You are blindly trusting user input. That is a bad thing. You're opening yourself up to destroying your database, either accidentally or maliciously. Google for "SQL Injection Attack" to find out why what you're doing is so bad.
|
|
|
|
|
Dear All,
I have revised this code based on my update information, but the record has not yet updated.
Please help me in adding and updating a data table.
My code is below, like that
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(Me.LatihanDataSet.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Update(Me.LatihanDataSet.datamahasiswa)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
The result : It have no a bug error, but the updated program have not run well.
Please help me to create the valid code for update a data.
Thank you for you time and attention,
My best regards,
Muljanto
modified 8-Aug-18 5:21am.
|
|
|
|
|
Dear Mr Dave,
I have done the some feedback.
- by restructuring the table adapter
- by putting the primary key
The result : It is no error bug, but the record has not yet updated succesfully.
The 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)
Please help me to rectify this code.
Thank so much for your time and attention,
My best regards,
Muljanto
|
|
|
|
|
Dear All,
I have revised this code, and putted the primary key on one field in DatamahasiswaTableAdapter1.
It does not run well.
Please help me in obtaining a solution about creating a code for adding and updating a data table.
My code is below, like that
Dim i As Integer
Dim update1 As DataTable = Me.DataGridView1.DataSource
Try
Me.Validate()
Me.LatihanDataSetBindingSource.EndEdit()
Me.LatihanDataSet.Tables(0).Rows(1).Item(1) = TextBox1.Text
i = DatamahasiswaTableAdapter1.Update(LatihanDataSet.datamahasiswa)
Me.DatamahasiswaTableAdapter1.Update(update1)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("no of rows updated=" & i)
The result : This happened the same bug error, like the previous one
Please help me to create the valid code for update a data.
Thank you for you time and attention,
My best regards,
Muljanto
|
|
|
|
|
|
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.
|
|
|
|