I m new to asp my code is working absolutely fine, but i am facing two problems although these problems are not affecting the application. I just want to make good functionality to the application logically.

1) when i upload excel file, and if another file is already present with the same name, then new file overwrites it..
and if i manually change file name then file is saved with new name..
i am trying to save this new file with unique name or new name,, i donít know how to do this pls help..

2) and second problem is that i want to save this file in db with the corresponding login user (for future reference).. i hope
my problems will be solved. many thanks

this is the url from which I got help..
shotdev.com/asp/asp-excel/asp-upload-excel-import-to-database/

code is pasted for review...


Code:
'upload_excel.asp               
<form action="upload_excel_process.asp" method="post" enctype="multipart/form-data" name="frmMain" onSubmit="return checkData();">
<input name="file1" type="file"> <input type="submit" name="Submit" value="Submit">
<%mem_id=session("mem_id")%>
<input type="hidden" name="client_id"  value="<%=mem_id%>">
</form>
process file

Code:
'upload_excel_process.asp
		 
<%client_id=session("mem_id")%>
<%
Dim xlApp,xlBook,xlSheet1,xlSheet2,OpenFile,i  
Dim Conn,strSQL,client_id,objExec  
Dim mySmartUpload  
Dim sFileName	

'*** Create Object ***'	
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'*** Upload Files ***'
mySmartUpload.Upload

	'** Getfile Name ***'
sFileName = mySmartUpload.Files("file1").FileName

If sFileName <> "" Then

mySmartUpload.Files("file1").SaveAs(Server.MapPath("excel/"&sFileName))

'   my ref..\excel\" & session("mem_id") & "\" & now()

OpenFile = "excel/"&sFileName

'*** Create Exce.Application ***'
Set xlApp = Server.CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(Server.MapPath(OpenFile))
Set xlSheet1 = xlBook.Worksheets(1)		

Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../db/database.mdb"),"" , ""
For  i = 2 To 5  
If Trim(xlSheet1.Cells.Item(i,1)) <> "" Then  
strSQL = ""  
strSQL = strSQL &"INSERT INTO add_contacts "  
strSQL = strSQL &"(client_id,name_receiver,contact_person_receiver,street_receiver,city_receiver,tel_receiver,fax_receiver,country_receiver,zip_code_receiver) "  

' i have added fields to the db for file (file_name and file_id) 

strSQL = strSQL &"VALUES "  
strSQL = strSQL &"('"&client_id&"', '"&xlSheet1.Cells.Item(i,1)&"','"&xlSheet1.Cells.Item(i,2)&"','"&xlSheet1.Cells.Item(i,3)&"'"  
strSQL = strSQL &",'"&xlSheet1.Cells.Item(i,4)&"','"&xlSheet1.Cells.Item(i,5)&"','"&xlSheet1.Cells.Item(i,6)&"','"&xlSheet1.Cells.Item(i,7)&"','"&xlSheet1.Cells.Item(i,8)&"')"

Set objExec = Conn.Execute(strSQL)  
Set objExec = Nothing  
End IF  
Next  



xlApp.Application.Quit

'*** Quit and Clear Object ***'
Conn.Close()
Set Conn = Nothing
Set xlSheet1 = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End If

Set mySmartUpload = Nothing
%>