Q
|
I am using the BRWS to log statistics to my database. Is there anyway I can get a unique identifier for a newly inserted row (such as using @@IDENTITY)? This is important so I can retrieve the information from the database and display it to the user.
|
A
|
The inserts performed by the BrowserHawk Reports Web Service (BRWS) take place asynchronously within the browser, so there's no way for the BRWS to return the @@IDENTITY of the new row to your script running on the server. However, there are a couple of things you can consider in this situation:
1) Consider showing the user the stats directly from the BH object by enumerating it. In other words, instead of having BH write the data to SQL, and then reading the data back out of SQL - just show them the data directly from BH like this (ASP code, other languages support enumeration similarly:
for each prop in bhObj
response.write prop & ": " & bhObj(prop)
next
2) When calling LogData to record the stats you can specify up to 5 custom values to be stored in the db (into columns userdata, userdata2,..., userdata5 respectively). So you could do something like this (pseudo-code):
rand = generate a unique random ID
call LogData, pass in value of rand variable to be stored in userdata2 field
select stats from db where userdata2 = rand
|