|
Subject:
|
NEED HELP! retrieving from database
|
|
Posted By:
|
nvillare
|
Post Date:
|
12/2/2003 6:38:29 AM
|
am working on a project on vb.net, a windows service. I am trying to compare two fields in a database, and increment a counter and place its value in another field of the database. I conceptually understand how to do it, but am unable to code it. I then want to create a code that will get the field with the highest increments and display it on the interface. Does anyone have any ideas? I NEED SOME HELP!!!
Thanks!
nvillare
|
|
Reply By:
|
nvillare
|
Reply Date:
|
12/2/2003 6:39:43 AM
|
I guess another thing I would need is looping thru a dataset.
Thanks!
nvillare
|
|
Reply By:
|
planoie
|
Reply Date:
|
12/2/2003 9:22:48 AM
|
Are the fields you are comparing getting changed externally and your service is watching to see that they changed?
Peter ------------------------------------------------------ Work smarter, not harder.
|
|
Reply By:
|
nvillare
|
Reply Date:
|
12/2/2003 12:26:13 PM
|
It is supposed to be a sniffer windows service. THe service picks up the packets and send them to a database. I am also having trouble with that. The interface gets the information from the database and displays it to the user. What I am having trouble on this part, is getting the interface to perform a SQL that states, look at each field for the highest occurence IP address, display that IP address along with its information, source, destination, time and date. What the service does is get the IP packets from the network insert them into the database. It first checks to see if it is already on the database, if it is, it increments the "reoccurence" field by one, if it's not, it makes a new entry into the database. This is where the interface loops through each row in the "reoccurence" field and checks which one has the highest number to display as previously mentioned.
Any help is greatly needed! I am completely lost!
Thanks!
nvillare
|
|
Reply By:
|
planoie
|
Reply Date:
|
12/2/2003 12:41:25 PM
|
Well... you don't need to loop thru anything to get the highest recurring value. You can use a simple select query that sorts based on that value.
For the updating/inserting part I'd recommend creating a stored procedure that handles the checking of an existing row, and does either an insert or an update accordingly. Put this in your stored procedure:
UPDATE myTable SET reoccurence=reoccurence+1 FROM myTable WHERE ipAddress=@ipAddress IF @@ROWCOUNT=0 INSERT INTO myTable VALUES(@ipAddress, 0)
This will attempt to update an existing record, if no rows are affected, the row doesn't exist, so insert it.
Peter ------------------------------------------------------ Work smarter, not harder.
|
|
Reply By:
|
cnmoto
|
Reply Date:
|
10/22/2004 12:37:47 AM
|
i have this problem!
|