xeroxcanada
asked on
Prefill form with Incremental 9 didgit number
I have a form that once filled will insert the data into a table called TempGIS
The form requires that you enter in a log number.
I want this log number to be prefilled when the person access the page and that number should not be a number that is already in the Table tempGIS.
So basicly each time a person visits the page a UNIQUE number will be prefilled in the Log_ID field.
Can this be done?
The form requires that you enter in a log number.
I want this log number to be prefilled when the person access the page and that number should not be a number that is already in the Table tempGIS.
So basicly each time a person visits the page a UNIQUE number will be prefilled in the Log_ID field.
Can this be done?
ASKER
When the page loads and runs the procedure how do I get the Log_ID in a form field on that page.
That depends on what language you are using and how you do your database connections currently. When that procedure executes, it will return a value. The value will be a single record, single column called LogID.
ASKER
I am using Dreamweaver and ASP. So when the page loads runs the procedure do I create a varailable called Log_ID and put that into the Form Field?
Also when trying to create the table TEMPGIS_Log_ID I get the following error.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'getdate'.
Also when trying to create the table TEMPGIS_Log_ID I get the following error.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'getdate'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You both for your help. Although both Items could have solved my problem I used only one and will keep the other option on the back burner.
I have included the Code that I used to solve the question.
Again Thank you very much for such a fast response
I have included the Code that I used to solve the question.
Again Thank you very much for such a fast response
<%
Function createGuid()
Set TypeLib = Server.CreateObject("Scriptlet.TypeLib")
tg = TypeLib.Guid
createGuid = left(tg, len(tg)-2)
Set TypeLib = Nothing
End Function
%>
<%guidis = RIGHT(createGuid,9) %>
create table TempGIS_LogID
(LogID int identity(1,1) primary key clustered
,usedate datetime getdate())
and a retrieval procedure
create procedure up_GetLogId
as
insert into tempGIS_logid(usedate) values (getdate())
select '000000000' + cast(scope_identity() as varchar(9)) as LogID
go
Now if you execute up_GetLogId when you load your page, you will have a preallocated ID that can't be reused.