473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Progress Bar

Dear All vb.net programmers,

I am new to vb.net. I would like to know how to make a progress bar show progress while saving binary data to the database. Please see below for the code I have so far. Please excuse the mess it is need of tiding up when the app is complete

On Error Resume Next
Dim x As Integer
Dim n As Integer

n = 1

Me.ToolStripProgressBar1.Maximum = 100
ToolStripProgressBar1.Step = 1
For x = 0 To n + 1






'see if the user has entered any information
Select Case DocumentTextBox.Text
Case Is = ""
MessageBox.Show("Please browse for the scanned document")
Exit Sub
Case Is = "Please browse for the scanned document"
MessageBox.Show("Please browse for the scanned document")
Exit Sub
End Select

Select Case DocumentIDTextBox.Text
Case Is = ""
MessageBox.Show("Please Enter the Document ID")
Exit Sub
Case Is = "Please enter Document ID"
MessageBox.Show("Please Enter the Document ID")
Exit Sub
End Select

Select Case CustomerTextBox.Text
Case Is = ""
MessageBox.Show("Please enter the Customer Name")
Exit Sub
Case Is = "Please enter the customer name"
MessageBox.Show("Please enter the Customer Name")
Exit Sub
End Select

Select Case DeliveryNumberTextBox.Text
Case Is = ""
MessageBox.Show("Please enter the delivery number")
Exit Sub
Case Is = "Please enter the delivery number"
MessageBox.Show("Please enter the delivery number")
Exit Sub


End Select
'-----------------------------------------------------------------------------------
'check that the document number doesn't exist
' ----- Connect to the database.

Dim theDatabase As New SqlClient.SqlConnection("Server=ws045\sqlexpress;d atabase=dbimages;integrated security=true")
theDatabase.Open()

' ----- Build the basic command.
Dim theCommand As New SqlClient.SqlCommand()
theCommand.CommandType = CommandType.StoredProcedure
theCommand.Connection = theDatabase
theCommand.CommandText = "GetRecordName"

' ----- Add the input parameter. In this case,
' use a test value of 25.
theCommand.Parameters.AddWithValue("@PriKey", Me.DeliveryNumberTextBox.Text)

' ----- Add the output parameter.
Dim outParam As SqlClient.SqlParameter = _
theCommand.Parameters.Add( _
"@nameresult", SqlDbType.NVarChar, 50)
outParam.Direction = ParameterDirection.Output

' ----- Run the stored procedure.
theCommand.ExecuteNonQuery()

' ----- The parameter has been updated for us.
'MsgBox(outParam.Value.ToString)

'If outParam.Value.ToString = Me.DocumentIDTextBox.Text Then
' MessageBox.Show("This record already exists")
'End If

' ----- Clean up.
theCommand = Nothing
theDatabase.Close()
theDatabase.Dispose()
If outParam.Value.ToString = Me.DeliveryNumberTextBox.Text Then
MessageBox.Show("This delivery number already exists in the database", "Incorrect Data Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.DeliveryNumberTextBox.Select()
Exit Sub
End If

If Me.DocumentIDTextBox.Text.StartsWith("DOC") = False Then
MessageBox.Show("Please enter the full document number starting with DOC", "Data Entry Validation", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DeliveryNumberTextBox.Select()
Exit Sub

End If

If Me.DocumentIDTextBox.Text.Length < 10 Then
MessageBox.Show("Insufficient characters, there must be 10 characters", "Data Validation", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DeliveryNumberTextBox.Select()
Exit Sub
End If

If Me.DeliveryNumberTextBox.Text.StartsWith("DEL") = False Then
MessageBox.Show("Delivery number must start with DEL", "Data Validation", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DeliveryNumberTextBox.Select()
Exit Sub

End If

If Me.DeliveryNumberTextBox.Text.Length < 10 Then
MessageBox.Show("Insufficient characters, there must be 10 characters", "Data Validation", MessageBoxButtons.OK, MessageBoxIcon.Error)
DeliveryNumberTextBox.Select()
Exit Sub
End If

Dim con As New SqlConnection("Server=ws045\sqlexpress;database=db images;integrated security=true")
Dim da As New SqlDataAdapter("SELECT * FROM MyImages", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()

da.MissingSchemaAction = MissingSchemaAction.AddWithKey

Dim fs As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
'Dim fs As New FileStream("C:\Windows\gone fishing.bmp", FileMode.Open, FileAccess.Read)
Dim MyData(fs.Length) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
con.Open()
da.Fill(ds, "MyImages")

UploadDate.Text = Date.Now

Dim myRow As DataRow
myRow = ds.Tables("MyImages").NewRow()
myRow("DocumentNumber") = DocumentIDTextBox.Text
myRow("DeliveryNumber") = DeliveryNumberTextBox.Text
myRow("Customer") = CustomerTextBox.Text
myRow("CurPC") = CurPC.Text
myRow("curuser") = CurUser.Text
myRow("uploadDate") = UploadDate.Text
myRow("imgField") = MyData
ds.Tables("MyImages").Rows.Add(myRow)
da.Update(ds, "MyImages")


fs = Nothing
MyCB = Nothing
ds = Nothing
da = Nothing

con.Close()
con = Nothing


MsgBox("File saved to database")

Kill("C:\Documents and Settings\" & Me.CurUser.Text & "\Desktop\Scanned Document\" & Me.DocumentTextBox.Text & ".pdf")

CustomerTextBox.Text = "Please enter the customer name"
CustomerTextBox.ForeColor = Color.Gray
DocumentIDTextBox.Text = "Please browse for the scanned document"
DocumentIDTextBox.ForeColor = Color.Gray
DocumentTextBox.Text = "Please browse for the scanned document"
DocumentTextBox.ForeColor = Color.Gray
DeliveryNumberTextBox.Text = "Please enter the delivery number"
DeliveryNumberTextBox.ForeColor = Color.Gray

Me.SaveButton.Select()

Next x


ToolStripProgressBar1.PerformStep()





ToolStripProgressBar1.Value = 0
Sep 26 '07 #1
0 1064

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: SpamProof | last post by:
I got an animated gif that is a barber pole spinning that I want to use as a progress bar. The problem is that is stops spinning (shows 1 frame) when my browser is processing a submited request...
7
by: Pepi Tonas | last post by:
I have a form that takes some time to load because it has to populate some Data. I was trying to display a form on top of it with an activity bar so that user can see that something's going on. ...
1
by: scorpion53061 | last post by:
this code came from cor and I think Armin authored it. I am trying to download an access database and track its progress. It is reading the size fo the file but I am unsure of how to get the...
8
by: Brian Henry | last post by:
I created a smooth progress bar with this code.. but if you update the values in a row quickly of it and watch it on screen it flickers... how would i change this to reduce the flickering?...
8
by: WhiteWizard | last post by:
I guess it's my turn to ASK a question ;) Briefly my problem: I am developing a Windows app that has several User Controls. On one of these controls, I am copying/processing some rather large...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
15
by: eladla | last post by:
Hi! I am creating a composite control the does some of it`s own data access. I want to display a progress bar between the time the page is loaded and the control place holder is displayed and...
5
by: Aggelos | last post by:
Hello I am doing sevreral scripts like sending a newsletter that might take a while to finish first to prevent the browser from timing out and to keep the user informed of the process progress I...
1
by: Bob | last post by:
Hi, I am having trouble seeing how this bolts together. The UI starts a process which involves a long running database update. All Database activity is handled by a class called DT. DT has a...
0
by: jags_32 | last post by:
Hello We use MFG-PRO as our ERP system which in turn uses Progress databases. In the old version of SQL 2000, using DTS packages, we used to set the code page via command prompts and execute DTS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.