|
Hi Everyone,
I hope I'm posting this in the right place. I'm using VistaDb version 6.2 I have a Main Database with several tables Like Clients, Inventory, etc. I have a Backup Database with the same table(s) and structure as the Main database. I'm trying to copy 1 or more records from the Backup Database, like the Inventory Table to the Main Database Inventory Table. The code below is inserting records from the Main database inventory table, and not from the backup database. Do I need to do this by First selecting the data and placing it in a tmp table then insert the records from the tmp table? Any help would be appreciated.
Here is the code I have:
Private Sub TransferInventory()
Dim MyFile As String = TreeListTransfer.FocusedNode(0).ToString
Dim VdbConn1 As String = "Data Source=" & Application.StartupPath & "\Backup\" & MyFile & ".vdb6"
Try
For i As Integer = 0 To LstFiles.Items.Count - 1
LstFiles.SelectedIndex = i
FileId = CInt(LstFiles.Text)
Using conn As New VistaDBConnection(VdbConn)
conn.Open()
StrSql = "INSERT INTO Inventory(ClientId, Category, Product, PartNo, PurchaseDate, Unit, UnitPrice, InStock, OnOrder, Photo)
SELECT ClientId, Category, Product, PartNo, PurchaseDate, Unit, UnitPrice, InStock, OnOrder, Photo
FROM dbo.Inventory
WHERE (InventoryId = @InventoryId)"
Using cmd As New VistaDBCommand(StrSql, conn)
With cmd.Parameters
.AddWithValue("@InventoryId", FileId)
End With
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
Next
MessageBox.Show("Transfer successfully completed on the 'Inventory' table", "Transfer Inventory Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Transfer Inventory Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
Finally
End Try
End Sub
Thanks in Advance.
|
|
|
|
|
|
Hello
How we can get the Percentage of any Process?
for example we have the the following:
Private Sub My_Process()
----Code
----Code
End Sub
this My_Process will have a lot of codes and process and may will take a time to finish
Is there a way to measure the achievement percent of M_Process while process?
thanks regards
|
|
|
|
|
That's only possible if you have some metric for how many items the process has to work on.
Such as records in a database or file.
But you could also add logging such as
Part 1 Beginning
Part 1 Success
Part 2 Beginning
Part 2 Success
...
|
|
|
|
|
Thanks sir for reply
other option
could we do the following:
Private Sub My_Process()
Timer1.Start
----Code
----Code
Timer1.Stop
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'What we should do here to link progress bar to timer in Parallel ???
End Sub
mean we shall measure the time for whole process
then we need to link that time to ProgressBar to show where we are in process
but here also must link the ProgressBar to timer in Parallel
May be we can use threading start ProgressBar and TimerTick??
Does that Possible?
If so, can show main function or code to achieve that?
modified 19-Jun-22 6:32am.
|
|
|
|
|
Are you saying that you're trying to estimate the amount of time the entire process will take?? That also requires that you know how many items you're going to be processing.
|
|
|
|
|
Another Option here
we could use "BackgroundWorker" as following:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = ???? Here what should put?
BackgroundWorker1.WorkerReportsProgress = True
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'We can measure this loop for example
For t = 0 To myMax
Label1.Text = t
BackgroundWorker1.ReportProgress(t)
Threading.Thread.Sleep(100)
Next
'But we need to measure process percentage of (My_Process()) ,
'No have (t) digital counter to use in (BackgroundWorker1.ReportProgress(t))
'So what is the solution here???
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label1.Text = e.ProgressPercentage.ToString() & " %"
ProgressBar1.Value = e.ProgressPercentage
ProgressBar1.Refresh()
End Sub
Private Sub My_Process()
---- Code
End Sub
modified 19-Jun-22 10:31am.
|
|
|
|
|
Have your method accept an IProgress<T> Interface (System) | Microsoft Docs[^] implementation, and call it to report the progress.
The caller will need to pass in an appropriate implementation - eg: Progress<T> Class (System) | Microsoft Docs[^].
But as already mentioned, you will need to know how much work your method needs to do if you want to report how far through the work it has got.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How about this approach ...
1) Run the process as a test, collecting the total time it takes. Call it "T"
2) Store that run time somewhere
3) Next time you run the process you can now use "T" as the denominator to calculate the percent complete. p = duration_now/T
4) If the percentage calculation goes over 100, then set it 100.
5) Capture the new total time, "T", store it for the next iteration.
Rinse, repeat.
Not perfect, but it might work for you.
|
|
|
|
|
Hi
I've wrote this code
With NewHS
.Lines = nLijnen
.PlayDate = Now
Console.SetCursorPosition(10, 21)
Console.Write("New highscore. " & nLijnen & " Your name please? ")
.Name = Console.ReadLine
.Name = .Name.Trim
If .Name = "" Then .Name = "[No Name]"
End With
When running the line console.readline It asks for two enters to accept. I see the cursor movingto the begin of the next line by the first enter.
The second time the program runs those lines of code it working well with one enter.
I'm clearing the keyboardbuffer before starting writing to the console with
Sub ClearKBBuffer()
While Console.KeyAvailable
Console.ReadKey(True)
Console.ReadKey()
End While
End Sub
Any Idea why or how to solve this.
Jan
|
|
|
|
|
I just tried your initial code (with various responses) and it works with only one press of the Enter key.
|
|
|
|
|
The whole code where start is the real game
<TargetFramework>net6.0</TargetFramework>
Sub ClearKBBuffer()
While Console.KeyAvailable
Console.ReadKey(True)
End While
End Sub
Sub Main()
Dim k As ConsoleKey
Console.TreatControlCAsInput = True
Randomize()
Do
Console.CursorVisible = False
Dim nLijnen = Start()
ClearKBBuffer
Console.CursorVisible = True
Dim hs As HighScores = HighScores.Load()
Console.BackgroundColor = ConsoleColor.Red
Console.ForegroundColor = ConsoleColor.Black
Dim NewPLace As Integer = -1
For i As Integer = 0 To 9
If nLijnen > hs.Scores(i).Lines And NewPLace < 0 Then
NewPLace = i
End If
Console.SetCursorPosition(10, 10 + i)
Console.Write(hs.Scores(i).Name.PadRight(30) & hs.Scores(i).Lines.ToString.PadLeft(10) & " " & hs.Scores(i).PlayDate.ToString("dd/MM/yyyy HH:mm:ss"))
Next
Console.Beep()
If NewPLace >= 0 Then
Dim NewHS As New Score
With NewHS
.Lines = nLijnen
.PlayDate = Now
Console.SetCursorPosition(10, 21)
Console.Write("New highscore. " & nLijnen & " Your name please? ")
.Name = Console.ReadLine
.Name = .Name.Trim
If .Name = "" Then .Name = "[No Name]"
End With
For i = 8 To NewPLace Step -1
hs.Scores(i + 1) = hs.Scores(i)
Next
hs.Scores(NewPLace) = NewHS
hs.Save()
End If
Console.SetCursorPosition(0, Console.WindowHeight - 2)
Console.WriteLine("New game? (Y/N) ")
Do
k = Console.ReadKey.Key
Loop While k <> ConsoleKey.Y And k <> ConsoleKey.N
Loop While k = ConsoleKey.Y
End Sub
|
|
|
|
|
Sub ClearKBBuffer()
While Console.KeyAvailable
Console.ReadKey(True)
Console.ReadKey()
End While
End Sub
Surely that will block when there are an odd numbers of keys in the input queue.
Did you mean this
Sub ClearKBBuffer()
While Console.KeyAvailable
Console.ReadKey(True)
End While
End Sub
Alan.
|
|
|
|
|
That was stupit wasn't it
|
|
|
|
|
I need to build a database using vb6 and ms access for various groups or organisation which have various members, can someone suggest how to build this kind of database using ms-access, one table will have the organisation information such as its name, establishment date etc, and another database which store members for each organisation, these organization can have members of 5 nos. to 20 or more numbers, can anyone suggest how to build this kind of database, would be more grateful if someone can give a free code for this type of database.
Thanks in advanvce
Zela
|
|
|
|
|
|
Thanks for the response and suggestion, I'm not into programming deeply, just need to create a simple database which keep record for some 50/100 nos of organisation which have its name and address along with the organisation members using vb and ms-access since i have a little knowledge on this. I can manage building for the organisation but keeping record for each of the organisation members becomes a little difficult.
|
|
|
|
|
Hello
I have Seen this Article:
DataGridView – Stacked Header; talk about how to make Multi Layer head for DatagridView
it was on C# , I have translated to VB.net but there was some errors,
have made it before in VB.net ?
I try to attach Source code of VB.net but I have'nt seen attachment option
many thanks
|
|
|
|
|
You can add the relevant code, and full details of the errors into your question. Please ensure you add the correct <pre lang="VB"></pre> tags around the code.
|
|
|
|
|
thanks
what about if want to attached file?
|
|
|
|
|
There is no attach feature. You need to copy the code that has the problem and paste it into your question as I suggested above.
|
|
|
|
|
|
hello everyone I have the following format of a configuration file so I want to edit these values, the file has the following extension data.config
format
Image — Postimages[^]
Form
Image — Postimages[^]
|
|
|
|
|
And? You never asked a question or detailed a problem you're having.
That kind of file is just your normal, everyday .INI file, completely outdated nowadays.
|
|
|
|
|
Hi sir,
i'm already try to pool data into listview and it worked. But i need to pool the data using timer can anyone guide me ?
<pre> Try
Dim cmd As New FbCommand("SELECT A.EVENTDATE AS EVENTDATE ,A.PRIORITY AS PRIORITY ,B.CARDHOLDERID AS CARDHOLDERID," & _
"B.EMAIL AS EMAIL,B.NAME AS NAME,C.WINSOCKIPADDRESS AS WINSOCKIPADDRESS,A.DEVICEID AS DEVICEID, " & _
"D.DESCRIPTION AS DESCRIPTION " & _
" FROM EVENT A , CARDHOLDER B , COMMCHANNEL C, DEVICE D " & _
"WHERE (A.CARDHOLDERID = B.CARDHOLDERID)" & _
" AND (A.COMMCHANNELID = C.COMMCHANNELID) " & _
" AND (A.DEVICEID = D.DEVICEID) " & _
"AND A.CARDHOLDERID IS NOT NULL " & _
"AND B.USERDEFINED9 = 'STAFF' AND B.STATUS='Normal'" & _
" AND A.PRIORITY IS NULL " & _
"AND A.EVENTDATE >= CAST('TODAY' AS DATE) AND A.EVENTMSG = 'Access Granted' " & _
"ORDER BY A.EVENTDATE ASC", IBSSCN)
IBSSDR = cmd.ExecuteReader()
ListView1.Items.Clear()
Dim bFlag As Boolean = True
Do Until Not bFlag
While IBSSDR.Read
Dim touch As DateTime = Convert.ToDateTime(IBSSDR.Item("EVENTDATE"))
Dim date1 As String = touch.Date.ToString("dd/MM/yyyy")
Dim time1 As String = Format(touch, ("hh:mm:ss tt"))
Dim str(5) As String
Dim itm As ListViewItem
str(0) = IBSSDR.Item("CARDHOLDERID")
str(1) = IBSSDR.Item("NAME")
str(2) = date1
str(3) = time1
If IBSSDR.Item("EMAIL") Is DBNull.Value Then
str(4) = ""
Else
str(4) = IBSSDR.Item("EMAIL")
End If
itm = New ListViewItem(str)
ListView1.Items.Add(itm)
End While
bFlag = IBSSDR.NextResult
Loop
IBSSCN.ClearAllPools()
Catch ex As Exception
MsgBox(ex.Message)
End Try
I already add the timer :
<pre lang="VB">
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = True
Timer1.Interval = 6000
ListView1.Update()
ListView1.Refresh()
end sub
Can anybody help me, plz , tq
|
|
|
|