Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 ASP/SQL - several question

Author  Topic 

Max10128
Starting Member

10 Posts

Posted - 2006-08-21 : 11:04:38
Hi
Im relatively new to ASP/SQL and have been thrown into the deep end by work. Ive got courses to go on, but not for another 3-6months.

Ive got an ASP file calling a database using SQL. Once you hit the "go" button, it puts this data into an Excel file, under a new window (still showing the asp file in the address bar).

It currently shows:

1)
Item numbers that end in "0" i.e. 3.10, 12.20 appear as 3.1 and 12.2 respectively in the Bill of Materials … i.e. being treated as decimals … I need them to show-up as text.
************************************************** *******************
2)
When saving the spreadsheet … it would be good to get "X" to set the default file name to:
<Quote ID>_<Customer>_<Platform>_<version>.[xls|pdf]
************************************************** *******************
3)
When a spreadsheet is displayed, it is in an editable Excel format.
Is it possible to lock the file automatically when its opened or password protect it?
************************************************** *******************
4)
If a spreadsheet window is open and you try and open a new one, the old one pops-up/is still there. Need to be able to close the old one and re-open a new one automatically.

If necessary i will post the code.
Any takers?
Thanks

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-08-21 : 11:45:51
cross post
http://sqlteam.com/forums/topic.asp?TOPIC_ID=70792
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-21 : 11:50:59
absolutely a cross-post.
I was told i posted in the wrong forum and to post here. Best you read the thread before you post a message!
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-21 : 11:52:55
quote:
Originally posted by Max10128
2)
When saving the spreadsheet … it would be good to get "X" to set the default file name to:
<Quote ID>_<Customer>_<Platform>_<version>.[xls|pdf]



Answer:
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=X Quote ID_Customer_Platform_version.xls"
%>
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-21 : 12:21:21
quote:
Originally posted by Max10128

...Best you read the thread before you post a message! ....



Coooooool

Try
<%
response.Write "<td align=right>" & FormatNumber(itemno,2) & "</td>" & vbcrlf
%>


Srinika
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-21 : 12:32:06
quote:
Originally posted by Srinika
Try
<%
response.Write "<td align=right>" & FormatNumber(itemno,2) & "</td>" & vbcrlf
%>

Srinika



Hi
Im afraid not. The other option someone suggested was:
FormatNumber(itemno,0.00)
but this also didnt work either!!
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-21 : 12:45:32
Check ur code again

the following works fine for me

<body>
<%
dim itemno
itemno = 453

%>

The non formatted number is :
<%
response.Write "<td align=right>" & itemno & "</td>" & vbcrlf
%>
<br>
<br>
The formatted number is :
<%
response.Write "<td align=right>" & FormatNumber(itemno,2) & "</td>" & vbcrlf
%>

</body>


What did u get ?
U may need to refresh ur page!!

Go to the machine where IIS is running.
Just copy the above to a txt file and rename it as p.asp, put it in a folder having name t, right click on that folder and web-share it with the same name.

type the following in ur browser

http://localhost/t/p.asp

also check:

http://www.w3schools.com/vbscript/func_formatnumber.asp

Srinika
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-22 : 04:38:26
Hi
im going to do the mad thing and post a link to the .asp file (too much code to put in here,)!!

'itemno' crops up @ lines: 387/661/665/670/713/724
The key line being 670.

all this ^ shows you how little i know about ASP!!
www.mcdcs.co.uk/test.asp

thanks for any help you can provide.
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-22 : 08:05:34
did u try my suggestion?

Srinika
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-22 : 12:32:06
quote:
Originally posted by Srinika

did u try my suggestion?

Srinika




I did, but using the code from the ASP file. Something is formatting the field. Because it is only at level 1.10 that the zero is removed. At 1.10.10, it remains!!
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-22 : 12:47:18
Not clear
>> I did, but using the code from the ASP file. ?
>> Something is formatting the field. ?
>> Because it is only at level 1.10
>> that the zero is removed
>> At 1.10.10, it remains!!

I didn't put 1.10 or 1.10.10, so either of us may be confused!

First check whether MINE is working
if so --> make use of the Formatting Function as it is.
Else --> post what error u get

If ur issue is 1.10.10 is not formatting, ie. because its not a number.

Srinika
Go to Top of Page

Max10128
Starting Member

10 Posts

Posted - 2006-08-23 : 04:23:19
Right. Lets start again.
Here's what we get:

41.1 should in fact be 41.10. When 41.10.xx reaches 41.10.10, it is displayed.

This is the code i currently have in place, to produce the above screenshot (the big gaps between the code are shown using "*****"):

********************
Dim itemno
*****
itemno = 0
objADORS.movefirst

Do while Not objADORS.EOF
itemno = itemno + 1
*****
response.Write "<td align=right>" & FormatNumber(itemno,2) & "</td>" & vbcrlf
********************


When i try to follow your plan, i either get: "this page can not be found", or DW8 opens the asp file!! (at the moment i dont have 100% access rights - around 80%). Shows how little i know of ASP unless someone else has already done the leg work!!
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-23 : 06:34:38
U may not have followed the way I suggested. I asked u to do it, to be used as a Test File (so that u don't have to worry about the big gaps "********" or any other logic. U can concentrate on 1 at a time (eg. how to format when displaying)

Anyway
if ur concern is to have 41.10 as it is rather than 41.1, u may need to convert that to a string. Look for convert functions (in VB its CSTR).
May be u need to write a function
-- to check whether its numeric, then format it, then convert it to text.






Srinika
Go to Top of Page
   

- Advertisement -