Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading files

Status
Not open for further replies.

ozzroo

Technical User
Feb 28, 2003
182
0
0
AU
Anyone know a link to code which will allow me to work with to upload files (word docs, pdfs) to an sql server.

I want to also rename the file to include the client reference number which is an incremental id field in the database.

I want it to add the new registration to the database, then get the new allocated reference number and use that to link the updated cv in another table.

I have the registrations working fine. so a new client registers and gets the number 12345. This will then add the doc they uploaded to a 'document' table and will be linked to 12345

Any help?

Thanks
 
Ok. I can now upload files to the document table perfectly fine, but how would i get the client id from the clients table to link it to the document uploaded at time of registration.

my code adds the new user to the database and gives them a unique number. then i run the code to add the file to the database. this is the same form. i want it to pull through the created unique number so i know which documents are linked to which users.

i assume it adds the client first, so there must be a way i can get the information from the new registration

any ideas please
 
How would I use scope_identity with asp.net. I have looked at some tutorials online, but cant seem to get it working.

Any ideas or starter points

 
Here is my store procedure. But how would I use that scope_identity to insert a record in another table

Code:
Create Procedure InsertNewRegistration
)
@Title nvarchar(50)
@Forename nvarchar(255)
@Surname nvarchar(255)
@Company nvarchar(50)
@AddressLine1 nvarchar(255)
@AddressLine2 nvarchar(255)
@AddressLine3 nvarchar(255)
@AddressLine4 nvarchar(255)
@County nvarchar(50)
@Postcode nvarchar(255)
@Region nvarchar(50)
@HomePhone nvarchar(255)
@BusinessPhone nvarchar(255)
@MobilePhone nvarchar(255)
@Email nvarchar(50)
@Password nchar(10)
@AssociateRef int OUTPUT

)
AS

-- INSERT the new record
INSERT INTO dbo.Associates(Title, Forename, Surname, Company, AddressLine1, AddressLine2, AddressLine3, AddressLine4, County, Postcode, Region, HomePhone, BusinessPhone, MobilePhone, Email, Password )
VALUES(@Title, @Forename, @Surname, @Company, @AddressLine1, @AddressLine2, @AddressLine3, @AddressLine4, @County, @Postcode, @Region, @HomePhone, @BusinessPhone, @MobilePhone, @Email, @Password)

-- Read the just-inserted ProductID into @AssociateRef
SET @AssociateRef = SCOPE_IDENTITY()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top