Login | |
|
 |
urgent help ..Need a script to insert values into sql d... - 10/9/2008 6:58:22 AM
|
|
 |
|
| |
yspkiran
Posts: 3
Score: 0
Joined: 10/9/2008
Status: offline
|
hi every one ...my name is kiran..i am new to this forums...i need urgent help.... i am doing a project related to sqldatabase.. i need to read the values wich are scanned by the Netstumbler software and write the values into a table in sql database..i tried a lot but it is not working..here is the code i am working with... public d public p d=0 sub OnScanResult (SSID,BSSID,CapFlags,Signal,Noise,LastSeen) dim fso, fl, ts,Rs Dim objConnection,objRecordset,strSearchCriteria set fso = CreateObject("Scripting.FileSystemObject") on error resume next if d=1 then set conn = server.createobject("ADODB.Connection") conn.connectionstring = "Provider=SQLOLEDB;Data source=UT142503\SQLEXPRESS; initial catalog=testbed;" If conn.State=1 Then Msgbox "Connected" else Msgbox "Not Connected" End If conn.Open connectionstring 'New Contact Name strSQL = "INSERT INTO testbed.dbo.buffer (d_value, macid) VALUES ( '" & d &" ' , ' " & BSSID & " ' )" conn.Execute strSQL Response.Write "Data written to database!" Msgbox "Data written to database" conn.Close End If If strSQL.State=1 Then Msgbox "Connected" else Msgbox "Not Connected" End If End Sub sub OnScanComplete (FoundNew,SeenBefore,LostCOntact,BestSNR) d=d+1 End Sub I need to write the values of variable ' d ' and the values for BSSID given by the Netstumbler software into table called "buffer" in database.the sript is executing without any errors but the values are not written into the table. I cannot see any values in the table. I tried the sript for creating a excel file and exporting the values from software to excel. and then written a stored procedure to load the values to table.. it is working...but i need the script for directly connecting to database and writing the values to table....the sript for excel file is.... public d public p d=0 sub OnScanResult (SSID,BSSID,CapFlags,Signal,Noise,LastSeen) dim fso, fl, ts set fso = CreateObject("Scripting.FileSystemObject") on error resume next if d=1 then set ts = fso.OpenTextFile("c:\ap.xls", 2, True) else set ts = fso.OpenTextFile("c:\ap.xls", 8, false) end if ts.write(d) ts.write(" ") ts.Write(BSSID) ts.write(" ") ts.Write(Signal+100) ts.write(" ") ts.WriteLine(Noise) ts.Close() End Sub sub OnScanComplete (FoundNew,SeenBefore,LostCOntact,BestSNR) d=d+1 End Sub sub onDisableScan() msgbox(d) d=1 End sub plz help me as soon as possible i am waiting for your valuable suggestions..... Thank you very much for your hits...but i need ur valuable suggestions...
|
|
| |
|
|
|
 |
RE: urgent help ..Need a script to insert values into s... - 10/9/2008 1:24:41 PM
|
|
 |
|
| |
fosterr_2000
Posts: 115
Score: 0
Joined: 12/18/2004
From:
Status: offline
|
Either provider will work. They are just different ways / drivers that can be used to connect. I am not sure about the rest of your script but maybe this will be close. I am not sure why you are passing 6 vars into your sub and only using one of them? If this doesn't work please post the full script. public d public p d=0 sub OnScanResult (SSID,BSSID,CapFlags,Signal,Noise,LastSeen) on error resume next if d=1 then Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Driver={SQL Server};" & _ "Server=UT142503\SQLEXPRESS;" & _ "Database=testbed;" & _ "Trusted_Connection=yes;" Set objRSSQL = CreateObject("ADODB.Recordset") strSQL = "INSERT INTO testbed.dbo.buffer (d_value, macid) VALUES ('" & d & "', '" & BSSID & "')" objRSSQL.Open strSQL, objConnection Response.Write "Data written to database!" Msgbox "Data written to database" End If sub OnScanComplete (FoundNew,SeenBefore,LostCOntact,BestSNR) d=d+1 End Sub Hope this helps.
|
|
| |
|
|
|
|
|