|
Well, you can't bind a DataGridView to a multidimensional array, only a single.
A better solution would be to create a class that holds the information you need in member variables exposed by properties, then create an ArrayList, or some other IList or ICollection collection, to hold all of your objects. You can then bind the datagrid to that collection and edit the collection directly.
|
|
|
|
|
Thanks I will look at that.
|
|
|
|
|
Hey guys the problem that I am is this. I am writting a service that every five minutes goes out and requests a web page. And the problem that I am having is whenever I disconnect my computer for the internet, the service throws an error. I have tried implementing some error handling but I can't seem to figure it out. I would like to code somethingso that if in 30 seconds a response is not gathered then to abort the request and try again in five minutes. Here is the code that i currently have:
Imports System
Imports System.IO
Imports System.Net
Imports System.Threading
Public Class VirasecHB
'Declare the Thread
Private VirasecHB_Thread As New Thread( _
New System.Threading.ThreadStart(AddressOf waitProcedure))
'Declare Variables
Dim serverID As String = "1336"
Dim webURL As String = "http://www.virasec.com/intranet/tech/heart/heartdb.asp?hdur=300&hsid=" & serverID
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
WebRequestProcedure()
VirasecHB_Thread.Start()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
VirasecHB_Thread.Abort()
End Sub
Private Sub WebRequestProcedure()
' Create a request for the URL.
Dim request As WebRequest = WebRequest.Create(webURL)
' If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials
'Sets web request timeout time
request.Timeout = 30000 ' 30000 = 30 Seconds
' Get the response.
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
'Close the response request
response.Close()
End Sub
Private Sub waitProcedure()
Do
'Wait Five Mintues
System.Threading.Thread.Sleep(300000) '300000 = 5 Minutes
Try
WebRequestProcedure()
Catch ex As Exception
Dim errorLog As New EventLog
errorLog.WriteEntry("Virasec Heartbeat Service " & _
"has encountered an error while trying to " & _
"connect to the Virasec web server. " & _
"The service will attempt to " & _
"connect again in five minutes.", EventLogEntryType.Error)
End Try
Loop
End Sub
End Class
If there is anything you guys can do to help please let me know.
Thanks again,
Travis
|
|
|
|
|
tcombs07 wrote: the problem that I am having is whenever I disconnect my computer for the internet, the service throws an error.
This line might be the problem...No internet connection, no getting to www.virasec.com.......
tcombs07 wrote: Dim webURL As String = "http://www.virasec.com/intranet/tech/heart/heartdb.asp?hdur=300&hsid=" & serverID
|
|
|
|
|
You have to mention the Error you're getting to get more precise answers.
I can only make a wild guess with the information you've provided.
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
In most probability, the CType you're doing is throwing an error as the Reponse object returned by the GetResponse() method will be null if it can't reach the Http server.
Enclose the above line in a Try..Catch block.
AND, next time, post the error message or what it says, as well.
SG
|
|
|
|
|
You'd have to completely redesign this. All of your code was written on the assuption that the request would work and only the occasional error would happen.
Turn it around and design the service so that it assumes that every request to the site will FAIL. For instance, this:
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
'Close the response request
response.Close()
always assumes that the response returns an object that you can close. Don't call close on an object that you don't know exists. Test for an object first, THEN call close on it if it's legitimate:
Dim response As ...
If response Is Nothing Then
' The request obviously failed...
Else
response.Close()
End If
|
|
|
|
|
Hello all,
Here's my situation:
I have a form with a listbox and a textbox, both with the same collumn of a databasetable.
When i click an item in the listbox i want the textbox to show the item as well.
I tried the following code:
Me.BindingContext(dsGroepAgent, "groep").Position = lstgroepen.SelectedIndex
When i click an item in the listbox the following error occured:
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
Any idea
|
|
|
|
|
You better don your asbestos suit for posting this in the programming forums, where, if you bothered to read the Posting Guidlines, posts like this are expressly forbidden.
|
|
|
|
|
Dave Kreskowiak wrote: You better don your asbestos suit for posting this in the programming forums, where, if you bothered to read the Posting Guidlines, posts like this are expressly forbidden.
Where did the original post go? I wanted to flame it
|
|
|
|
|
It was a recruiter from TEKsystems, posting a job opening in Illinois. You know, the exact same email he blindly sends to hundreds of people, praising their resume, without having even seen it!
|
|
|
|
|
Dave Kreskowiak wrote: It was a recruiter from TEKsystems, posting a job opening in Illinois.
Oh, that guy. I just barked at him for cross-posting and actually did a friendly suggestion of the CP job board :->
|
|
|
|
|
Hi,
I am new in programming, I involved in development new project related to point of sales using Visual Basic.Net , i need some tips about how to make bar code reader (or Manually) can read the code on the items, and put it in datagrid of the project.
.... Please some help
thanks
new member
|
|
|
|
|
Mr. Wonderful wrote: I am new in programming
You're in WAY over your head already. This is a very complicated project for someone who has little experience in programming, let alone using specialized hardware like this.
The barcode reader simply reads the code from the item and sends that number t your code. How you get it depends entirely on the barcode reader you're using. Some send the data over a serial port, others over TCP/IP, and still others through the keyboard, just like the user typed the code.
You put the data into a database, not a DataGrid. There's tons of examples all over the web, you simply have to Google for something like "insert data into Access database VB.NET", or whatever database engine you're using.
|
|
|
|
|
Mr Dave,
Although I expect your replying, I didn't mean explain all about how to filter data into datagrid, but I mean to how to begin. I know I'm not a professoinal developer to develop like this project, but just all I want is guid me how to begin, and you did it, thanks again.
regards
|
|
|
|
|
hello,
how can i see for how much % the processor (CPU) is being used? (just like in the task manager) Thanks in advance,
--Zaega--
|
|
|
|
|
I found this example awhile ago, and it's still the only way that I've found to read CPU usage that actually works.
Dim eIdle As Int64
Dim eKernel As Int64
Dim eUser As Int64
Dim sIdle As Int64
Dim sKernel As Int64
Dim sUser As Int64
Dim cIdle As Int64
Dim cKernel As Int64
Dim cUser As Int64
Dim systemTime As Int32
Dim totalCpuUsage As Single 'Long 'Int64
Public Declare Auto Function GetSystemTimes Lib "kernel32.dll" (ByRef idleTime As Int64, ByRef kernelTime As Int64, ByRef userTime As Int64) As Boolean
Dim updateSpeed As Integer = 500
Public Sub GetCPUUsage()
'Retrieve the Times values before starting the delay.
GetSystemTimes(sIdle, sKernel, sUser)
'The delay for how often to check and update the cpu usage values.
Threading.Thread.Sleep(updateSpeed)
'Retrieve the Times values after the Delay.
GetSystemTimes(eIdle, eKernel, eUser)
'Get the values calculated between the starting and ending Times values.
cIdle = (eIdle - sIdle)
cKernel = (eKernel - sKernel)
cUser = (eUser - sUser)
'Calculate the total system time. Which is Kernel and User time together.
systemTime = (cKernel + cUser)
'Simply check if the rounded option is true or not and display the usage value.
totalCpuUsage = (systemTime - cIdle) * (100) \ (systemTime)
'System.Windows.Forms.Application.DoEvents()
CPUUseLbl.Text = "CPU Usage: " & totalCpuUsage.ToString & "%"
Dim Ok As Integer = 0
End Sub
Hope this helps.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
That's a ton of work for something that's supplied by the PerformanceCounter class already...
[EDIT] Helps if I put the correct class name in...
-- modified at 14:45 Monday 14th May, 2007
|
|
|
|
|
Dave Kreskowiak wrote: That's a ton of work for something that's supplied by the PerformanceCounter class already...
My exact thoughts
|
|
|
|
|
Thanks all
|
|
|
|
|
The CPU percentage has a couple of parts, user time and kernel time. They are calculated when the measurement it taken, not accumulated over the life of a process.
You can get the current percentages using the PerformanceCounter class. Look up "performancecounter components" in MSDN and you'll find a bunch of examples.
|
|
|
|
|
Hello
VS 2005,
I am developing MDI application. The user would like to have an timer running in the back ground that will send e-mail every 5 times.
Sending the e-mails is not the problem, but how can I control the timer in the back ground.
On one of the mdi forms the user will select send e-mails (start timer) and on this same form the user can stop sending e-mails (stop timer).
Would a timer control in the main form be ok? If so, then the mdi form that controls the start and stop should be able to communicate this to the main form. If the form that starts and stops the timer is closed the timer should still run. The timer should run until the application is completely closed by the user.
Any suggestions or code examples would be most grateful,
Thanks,
Steve
|
|
|
|
|
You can do it in two ways.
1. Have a hidden form that has this timer and which can be controlled by other forms (ungainly approach)
2. Create an instance of System.Timers.Timer in your MDI Form, add an event delegate to the Elapsed event of the Timer object you created and have your email logic put in a separate class file, which can be called from the Elapsed event.
The Timer you see in the toolbox is the Windows.Forms.Timer object, apart from this, you can also use System.Timers.Timer and System.Threading.Timer.
Regards,
SG
|
|
|
|
|
Hello,
Thanks for your reply.
The 2 option sounds like the best. Can this be extended for many timers. As the user will want to be able to create many timers for many jobs. for example, if they have 5 jobs open, it should send 5 e-mails every 5 minutes.
Many thanks,
Steve
|
|
|
|
|
You shouldn't be setting up Timers all over the place. Your code should be written to fire a single Timer every minute, then in the event, check the current system time against the scheduled execution times of various items.
There is a limit to the number of Timers a single process can run. I think it's 32, but I seem to remember something about the type of timer being used too.
|
|
|
|
|
Hi All,
Please help me for packet drop/pass using VB6.
I have found winpcap and vbpcap for capturing packet but vbpcap is still not support packet drop/pass. Please help me for packet drop/pass.
|
|
|
|