NetStumbler.org Forums

Go Back   NetStumbler.org Forums > NetStumbler Community > Scripts
Register Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 12-30-2005   #1 (permalink)
Chris H
Registered Member
 
Join Date: Dec 2005
Posts: 11
A simple VBScript to update MS Access Database

Here's a quick and dirty VBScript that will update a Microsoft Access database with the list of AP's in real time. You could easily adapt this to MySQL, but I use Access since it is more portable and sufficient for this application. Hopefully, the formatting is preserved.

You'll need an Access database with a table named "APs" and columns named:

BSSID
SSID
MaxSNR
Latitude
Longitude
Altitude
FixType
CapFlags
DateTime

Or you can use the attached one.

All of the columns are text fields, with BSSID being the primary key though it doesn't HAVE to have a primary key, it prevents the possibility of two identical BSSIDs being stored in the database. Obviously you can customize this as you see fit. I recommend Aedix for VBScript editing.

Code:
Sub OnPositionChange(SSID, BSSID, CapFlags, MaxSNR, Lat, Lon, Alt, FixType)
'this function runs when NetStumbler updates the GPS location of an AP - ie strongest signal point
'we can use this to update our database in real time
If BSSID <> "000000000000" Then 'ignore bogus APs
	Set MyConn = CreateObject("ADODB.Connection")
	MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Network Stumbler\aps.mdb"
	Set RS = MyConn.Execute("SELECT * FROM APs WHERE BSSID = '" & BSSID & "'")
	SSID = Replace(SSID, "'", "") 'remove characters from SQL query that will crash it

	While Not RS.EOF
		'BSSID exists in database already, update it with latest info
	    MyConn.Execute "UPDATE APs SET SSID = '" & SSID & "', MaxSNR = '" & MaxSNR & "', Latitude = '" & Lat & "', Longitude = '" & Lon & "', Altitude = '" & Alt & "', FixType = '" & FixType & "', CapFlags = '" & CapFlags & "', DateTime = '" & Now & "' WHERE BSSID = '" & BSSID & "'"
		MyConn.Close
		Exit Sub
	Wend
	
	'this BSSID does not exist, must be added
	MyConn.Execute "INSERT INTO APs (BSSID, SSID, MaxSNR, Latitude, Longitude, Altitude, FixType, CapFlags) VALUES ('" & BSSID & "', '" & SSID & "', '" & MaxSNR & "', '" & Lat & "', '" & Lon & "', '" & Alt & "', '" & FixType & "', '" & CapFlags &  "', " & Now & ")"
	MyConn.Close
End If
End Sub
EDIT: You'll need to change the path of your access database in line 6.

EDIT part Deux: Attached a database you can use (for those of you without access to Access).
Attached Files
File Type: zip aps.zip (7.3 KB, 213 views)

Last edited by Chris H : 12-30-2005 at 09:12 AM.
Chris H is offline   Reply With Quote
Old 12-30-2005   #2 (permalink)
streaker69
Psychic Amish Stumbler
 
streaker69's Avatar
 
Join Date: Jul 2004
Location: Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
Posts: 11,708
Cool script, and there had been some people asking about that.

Question: Does it require any certain version of the MSJet or MDAC for it to run?
__________________
"One of these days, I'm going to cut you to pieces."

If you're offended by this post, please feel free to report it to one of the many helpful moderators of this forum.

Thank you.
streaker69 is offline   Reply With Quote
Old 12-30-2005   #3 (permalink)
Chris H
Registered Member
 
Join Date: Dec 2005
Posts: 11
Jet 4.0 should be sufficient. I should have but forgot to mention, the version of Access I used is 2003 but this should work with an Access 2000 database. I don't have Access 2000 to create and test one.

If someone wants to use my database as a template I can email it or upload it somewhere if someone has webspace.
Chris H is offline   Reply With Quote
Old 12-30-2005   #4 (permalink)
streaker69
Psychic Amish Stumbler
 
streaker69's Avatar
 
Join Date: Jul 2004
Location: Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
Posts: 11,708
Quote:
Originally Posted by Chris H
Jet 4.0 should be sufficient. I should have but forgot to mention, the version of Access I used is 2003 but this should work with an Access 2000 database. I don't have Access 2000 to create and test one.

If someone wants to use my database as a template I can email it or upload it somewhere if someone has webspace.
You know there is an SQL command that you could send that will create the db struture for you as long as the file exists?

But if you were to attach a blank database with the structure created to your original post that would probably be a big help for people that don't even have access to begin with.
__________________
"One of these days, I'm going to cut you to pieces."

If you're offended by this post, please feel free to report it to one of the many helpful moderators of this forum.

Thank you.
streaker69 is offline   Reply With Quote
Old 12-30-2005   #5 (permalink)
Chris H
Registered Member
 
Join Date: Dec 2005
Posts: 11
Quote:
Originally Posted by streaker69
You know there is an SQL command that you could send that will create the db struture for you as long as the file exists?

But if you were to attach a blank database with the structure created to your original post that would probably be a big help for people that don't even have access to begin with.
Yeah, that is true. That would take the work out of it for everyone.

I just noticed the attachments button, I'll attach an empty version of my database to my first post.
Chris H is offline   Reply With Quote
Old 12-30-2005   #6 (permalink)
streaker69
Psychic Amish Stumbler
 
streaker69's Avatar
 
Join Date: Jul 2004
Location: Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
Posts: 11,708
Quote:
Originally Posted by Chris H
Yeah, that is true. That would take the work out of it for everyone.

I just noticed the attachments button, I'll attach an empty version of my database to my first post.
Zip it first.
__________________
"One of these days, I'm going to cut you to pieces."

If you're offended by this post, please feel free to report it to one of the many helpful moderators of this forum.

Thank you.
streaker69 is offline   Reply With Quote
Old 12-30-2005   #7 (permalink)
wrzwaldo
I amuse you?
 
Join Date: Dec 2003
Posts: 9,127
Quote:
Originally Posted by Chris H
Yeah, that is true. That would take the work out of it for everyone.

I just noticed the attachments button, I'll attach an empty version of my database to my first post.

Nice! I've been wanting to write one but have been too busy [insert lazy] to do it.

Thanks
wrzwaldo is offline   Reply With Quote
Old 03-03-2006   #8 (permalink)
tuvelc
Registered Member
 
Join Date: Jan 2006
Posts: 2
I was trying the script but I do not understand than it so happens that he does not store nothing in data base to me, I am working access 2003 want knowing that it can be happening that he does not store nothing. I expect ready answer.

Tuvelc, mi email is tuvelc@yahoo.es
tuvelc is offline   Reply With Quote
Old 03-03-2006   #9 (permalink)
streaker69
Psychic Amish Stumbler
 
streaker69's Avatar
 
Join Date: Jul 2004
Location: Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
Posts: 11,708
Quote:
Originally Posted by tuvelc
I was trying the script but I do not understand than it so happens that he does not store nothing in data base to me, I am working access 2003 want knowing that it can be happening that he does not store nothing. I expect ready answer.

Tuvelc, mi email is tuvelc@yahoo.es
I believe you saying that you're trying to make this work, but it's not inserting any data into the Database.

Did you put the APS.MDB file in the correct path, or update the script to indicate where that file is located?

Did you start the script in NS?
__________________
"One of these days, I'm going to cut you to pieces."

If you're offended by this post, please feel free to report it to one of the many helpful moderators of this forum.

Thank you.
streaker69 is offline   Reply With Quote
Old 03-04-2006   #10 (permalink)
goldfndr
Knight Tooth Puller
 
goldfndr's Avatar
 
Join Date: Aug 2004
Location: Bellevue, WA, USA
Posts: 182
The functionality of this script has been merged into the newest release of the Master script for NetStumbler (set "UseDatabase" to True). And more - it will automatically create the database and tables for you and can filter. If you continue to have trouble with this thread's script, the "Master script" might be less hassle.
goldfndr is offline   Reply With Quote
Old 03-04-2006   #11 (permalink)
tuvelc
Registered Member
 
Join Date: Jan 2006
Posts: 2
I have a gps and netstumbler but the scritp don't save any data in the database, i want to help me pls with the script
tuvelc is offline   Reply With Quote
Old 03-04-2006   #12 (permalink)
streaker69
Psychic Amish Stumbler
 
streaker69's Avatar
 
Join Date: Jul 2004
Location: Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
Posts: 11,708
Quote:
Originally Posted by tuvelc
I have a gps and netstumbler but the scritp don't save any data in the database, i want to help me pls with the script
Then answer the damn questions that were already asked. Jumping Geebus on pogo stick we're not goddamn mind readers.
__________________
"One of these days, I'm going to cut you to pieces."

If you're offended by this post, please feel free to report it to one of the many helpful moderators of this forum.

Thank you.
streaker69 is offline   Reply With Quote
Old 03-04-2006   #13 (permalink)
Airstreamer
Sniffin' the aether
 
Airstreamer's Avatar
 
Join Date: Nov 2004
Location: A little North of Reason
Posts: 2,726
Quote:
Originally Posted by streaker69
Then answer the damn questions that were already asked. Jumping Geebus on pogo stick we're not goddamn mind readers.
I'll bet I know what YOU'RE thinking!!
__________________
"Wait just a minute, now. Whaddya mean, you DON'T use Regedit to send email?"
Airstreamer is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Google
 
Web NetStumbler.org

All times are GMT -7. The time now is 11:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 ©2007, Crawlability, Inc.


All messages express the views of the author and are for entertainment purposes only. Netstumbler.org cannot be held responsible for the authenticity of the content or the actions of its members. By using this site and its services, you warrant that you will not post any messages that are discriminating, obscene, hateful, threatening, or otherwise violates any laws and you release Netstumbler.org from any future claims of any kind whatsoever including, but not limited to, addiction and loss of productivity. All forum messages, private messages and any other content are properties of Netstumbler.org. Even if publicly available, personal or copyrighted information are not to be posted without the consent of the owner. Distribution of licensed and copyrighted materials in any way not endorsed by the copyright owner is strictly prohibited. You may not use this site and its resources to spam other sites or individuals or perform any action that violates any law. Items sold or bought in the For Sale forum are sold as is and no warranty or insurance of any kind is provided. Netstumbler.org cannot be held responsible for the outcome of any transactions and no warranty of any kind is provided, either express or implied. Vulgar words are not allowed in the subject lines ; they may be used in the message body in any forum. The Administrator, Super Moderators and Moderators of Netstumbler.org have the right to remove, edit, move or close any thread for any reason and to reveal your identity and other known information in the event of a complaint or legal action arising from any message posted by you.