teferi2002
Technical User
I'm not sure what is going on here but these files have always worked and now they are not. Nothing has changed with the server or the application. I also copied the working files from test to production.
The external server site:
click on upper right corner Comma-Separated Values
It will ask you to save the file. Looking at the screen you will see that it is stating it is showing File as metric.aspx and File Type as an ASPX file.
It is suppose to show it as File as MetricItemList.csv and File Type Microsoft Excel Comma Separated Values File. As in internal test site:
Can someone help me here
<%@ Page Trace="False" Debug="True" Language="VB" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<Html>
<Head>
<Title>Trns*port Item Lists (Metric System)</Title>
<style type="text/css">
<!--
.style4 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
</Head>
<Script runat="server" language="VB">
Dim myConnection as OleDbConnection
Dim dr as OleDbDataReader
Dim cmd as OleDbCommand
Dim connectionString as string
Dim i As Integer
Dim filename as string
Dim sb as System.Text.StringBuilder
Dim myConnectionc as OleDbConnection
Dim drc as OleDbDataReader
Dim cmdc as OleDbCommand
Dim connectionStringc as string
Dim StrSql as string
Sub page_load()
lblTime.Text =DateTime.Now.ToString()
connectionString = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
myConnection = new OleDbConnection(connectionString)
myConnection.Open()
StrSql= "SELECT (substr( ITEM ,1,4)||'.'||substr(item,5)) Item_Number, IDESCR Short_Description, IDESCRL Long_Description, IUNITS Unit_Name," & _
"(case when IUNITS = 'LS' THEN 'LUMP SUM' " & _
"when IUNITS = 'LS' THEN 'LUMP SUM' " & _
"when IUNITS = 'LB' THEN 'POUND' " & _
" when IUNITS = 'ACRE' THEN 'ACRE' " & _
"when IUNITS = 'C Y' THEN 'CU YD' " & _
" when IUNITS = 'DOL' THEN 'DOLLAR' " & _
" when IUNITS = 'GAL' THEN 'GALLONS' " & _
"when IUNITS = 'L F' THEN 'LIN FT' " & _
"when IUNITS = 'MBM' THEN 'M BOARD FT' " & _
"when IUNITS = 'MGAL' THEN 'M GALLONS' " & _
"when IUNITS = 'PLS' THEN 'PLANT' " & _
"when IUNITS = 'RDST' THEN 'ROAD STA' " & _
"when IUNITS = 'S F' THEN 'SQ FT' " & _
"when IUNITS = 'S Y' THEN 'SQ YD' " & _
" when IUNITS = 'SHRB' THEN 'SHRUB' " & _
"when IUNITS = 'STR' THEN 'STRUCTURE' " & _
"when IUNITS = 'SYIN' THEN 'SQ YD-IN' " & _
"when IUNITS = 'SYS' THEN 'SYSTEM' " & _
"when IUNITS = 'TON' THEN 'TON' " & _
"when IUNITS = 'TREE' THEN 'TREE' " & _
"when IUNITS = 'VINE' THEN 'VINE' " & _
"when IUNITS = 'WEEK' THEN 'WEEK' " & _
"when IUNITS = 'M' THEN 'm' " & _
"when IUNITS = 'M2' THEN 'm2' " & _
"when IUNITS = 'M3' THEN 'm3' " & _
"when IUNITS = 'HA' THEN 'ha' " & _
"when IUNITS = 'T' THEN 't' " & _
"when IUNITS = 'KG' THEN 'kg' " & _
" when IUNITS = 'YARD' THEN 'YARD' " & _
" ELSE IUNITS END) Plan_Unit_Description " & _
"FROM ITEMLIST " & _
" WHERE ISPECYR='01' AND IOBSELET='N' and ITEM <> '2999509/00001' "
cmd = New OleDbCommand(StrSql,myConnection)
dr = cmd.ExecuteReader()
dgMetric.DataSource =dr
dgMetric.DataBind()
connectionStringc = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
myConnectionc = new OleDbConnection(connectionStringc)
myConnectionc.Open()
filename = "MetricItemList.csv"
cmdc = New OleDbCommand(StrSql,myConnectionc)
drc = cmdc.ExecuteReader()
sb = New System.Text.StringBuilder
End sub
Sub Click(ByVal sender as System.Object, ByVal e as System.EventArgs)
'for field name
For i=0 to drc.FieldCount-1
If i < (drc.FieldCount-1) then
sb.Append(Chr(34)&drc.GetName(i)&Chr(34)&",")
Else
sb.Append(Chr(34)&drc.GetName(i)&Chr(34)& VbCrLf)
End If
Next
'for field value
While drc.Read()
For i=0 to drc.FieldCount-1
If i < (drc.FieldCount-1) then
sb.Append(Chr(34) & drc.GetValue(i).ToString.Replace(Chr(34),Chr(34) & Chr(34)) & Chr(34) & ",")
'sb.Append(Chr(34)&drc.GetValue(i).ToString & Chr(34)&",")
Else
sb.Append(Chr(34)&drc.GetValue(i).ToString & Chr(34)& VbCrLf)
End if
Next
End while
drc.close()
myConnectionc.Close()
Response.ContentType ="Application/x-csv"
Response.AddHeader("content-disposition","attachment;filename="""& filename &"""")
Response.Write(sb.ToString)
Response.End()
End Sub
</Script>
<Body>
<table width="100%" border="0" >
<form runat="server">
<p> <div align="center"><span class="style4">Bid Letting </span><br>
Trns*port Item Lists (Metric System -This list went into effect with the 2000 Spec. Book) <br>
<i> This list is a current download the time is now<B>: <asp:Label runat="server" id="lblTime" /></b> </i></p>
</div>
<P align="right"> Metric system item list data below as:
<asp:LinkButton id="btnSubmit" runat="Server" text=" Comma-Separated Values" OnClick="Click"/>
</P>
<hr>
<asp
ataGrid id="dgMetric" runat="server" autoGenerateColumns="false" cellpadding="4" width="100%">
<ItemStyle Font-Name="Arial" Font-Size="9pt" ForeColor="#000000"/>
<HeaderStyle Font-Name="Arial" Font-Size="9pt" Font-Bold="true" BackColor ="#003366" ForeColor ="#FFFFFF"/>
<AlternatingItemStyle Font-Name ="Arial" Font-Size ="9pt" BackColor ="#CCCCCC"/>
<columns>
<asp:boundColumn DataField="Item_Number" HeaderText="Item Number"/>
<asp:boundColumn DataField="Short_Description" HeaderText="Short Description"/>
<asp:boundColumn DataField="Long_Description" HeaderText="Long Description"/>
<asp:boundColumn DataField="Unit_Name" HeaderText="Unit Name"/>
<asp:boundColumn DataField="Plan_Unit_Description" HeaderText=" Plan Unit Description"/>
</columns>
</asp
ataGrid>
</form>
</table>
</Body>
</Html>
The external server site:
click on upper right corner Comma-Separated Values
It will ask you to save the file. Looking at the screen you will see that it is stating it is showing File as metric.aspx and File Type as an ASPX file.
It is suppose to show it as File as MetricItemList.csv and File Type Microsoft Excel Comma Separated Values File. As in internal test site:
Can someone help me here
<%@ Page Trace="False" Debug="True" Language="VB" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<Html>
<Head>
<Title>Trns*port Item Lists (Metric System)</Title>
<style type="text/css">
<!--
.style4 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
</Head>
<Script runat="server" language="VB">
Dim myConnection as OleDbConnection
Dim dr as OleDbDataReader
Dim cmd as OleDbCommand
Dim connectionString as string
Dim i As Integer
Dim filename as string
Dim sb as System.Text.StringBuilder
Dim myConnectionc as OleDbConnection
Dim drc as OleDbDataReader
Dim cmdc as OleDbCommand
Dim connectionStringc as string
Dim StrSql as string
Sub page_load()
lblTime.Text =DateTime.Now.ToString()
connectionString = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
myConnection = new OleDbConnection(connectionString)
myConnection.Open()
StrSql= "SELECT (substr( ITEM ,1,4)||'.'||substr(item,5)) Item_Number, IDESCR Short_Description, IDESCRL Long_Description, IUNITS Unit_Name," & _
"(case when IUNITS = 'LS' THEN 'LUMP SUM' " & _
"when IUNITS = 'LS' THEN 'LUMP SUM' " & _
"when IUNITS = 'LB' THEN 'POUND' " & _
" when IUNITS = 'ACRE' THEN 'ACRE' " & _
"when IUNITS = 'C Y' THEN 'CU YD' " & _
" when IUNITS = 'DOL' THEN 'DOLLAR' " & _
" when IUNITS = 'GAL' THEN 'GALLONS' " & _
"when IUNITS = 'L F' THEN 'LIN FT' " & _
"when IUNITS = 'MBM' THEN 'M BOARD FT' " & _
"when IUNITS = 'MGAL' THEN 'M GALLONS' " & _
"when IUNITS = 'PLS' THEN 'PLANT' " & _
"when IUNITS = 'RDST' THEN 'ROAD STA' " & _
"when IUNITS = 'S F' THEN 'SQ FT' " & _
"when IUNITS = 'S Y' THEN 'SQ YD' " & _
" when IUNITS = 'SHRB' THEN 'SHRUB' " & _
"when IUNITS = 'STR' THEN 'STRUCTURE' " & _
"when IUNITS = 'SYIN' THEN 'SQ YD-IN' " & _
"when IUNITS = 'SYS' THEN 'SYSTEM' " & _
"when IUNITS = 'TON' THEN 'TON' " & _
"when IUNITS = 'TREE' THEN 'TREE' " & _
"when IUNITS = 'VINE' THEN 'VINE' " & _
"when IUNITS = 'WEEK' THEN 'WEEK' " & _
"when IUNITS = 'M' THEN 'm' " & _
"when IUNITS = 'M2' THEN 'm2' " & _
"when IUNITS = 'M3' THEN 'm3' " & _
"when IUNITS = 'HA' THEN 'ha' " & _
"when IUNITS = 'T' THEN 't' " & _
"when IUNITS = 'KG' THEN 'kg' " & _
" when IUNITS = 'YARD' THEN 'YARD' " & _
" ELSE IUNITS END) Plan_Unit_Description " & _
"FROM ITEMLIST " & _
" WHERE ISPECYR='01' AND IOBSELET='N' and ITEM <> '2999509/00001' "
cmd = New OleDbCommand(StrSql,myConnection)
dr = cmd.ExecuteReader()
dgMetric.DataSource =dr
dgMetric.DataBind()
connectionStringc = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
myConnectionc = new OleDbConnection(connectionStringc)
myConnectionc.Open()
filename = "MetricItemList.csv"
cmdc = New OleDbCommand(StrSql,myConnectionc)
drc = cmdc.ExecuteReader()
sb = New System.Text.StringBuilder
End sub
Sub Click(ByVal sender as System.Object, ByVal e as System.EventArgs)
'for field name
For i=0 to drc.FieldCount-1
If i < (drc.FieldCount-1) then
sb.Append(Chr(34)&drc.GetName(i)&Chr(34)&",")
Else
sb.Append(Chr(34)&drc.GetName(i)&Chr(34)& VbCrLf)
End If
Next
'for field value
While drc.Read()
For i=0 to drc.FieldCount-1
If i < (drc.FieldCount-1) then
sb.Append(Chr(34) & drc.GetValue(i).ToString.Replace(Chr(34),Chr(34) & Chr(34)) & Chr(34) & ",")
'sb.Append(Chr(34)&drc.GetValue(i).ToString & Chr(34)&",")
Else
sb.Append(Chr(34)&drc.GetValue(i).ToString & Chr(34)& VbCrLf)
End if
Next
End while
drc.close()
myConnectionc.Close()
Response.ContentType ="Application/x-csv"
Response.AddHeader("content-disposition","attachment;filename="""& filename &"""")
Response.Write(sb.ToString)
Response.End()
End Sub
</Script>
<Body>
<table width="100%" border="0" >
<form runat="server">
<p> <div align="center"><span class="style4">Bid Letting </span><br>
Trns*port Item Lists (Metric System -This list went into effect with the 2000 Spec. Book) <br>
<i> This list is a current download the time is now<B>: <asp:Label runat="server" id="lblTime" /></b> </i></p>
</div>
<P align="right"> Metric system item list data below as:
<asp:LinkButton id="btnSubmit" runat="Server" text=" Comma-Separated Values" OnClick="Click"/>
</P>
<hr>
<asp
<ItemStyle Font-Name="Arial" Font-Size="9pt" ForeColor="#000000"/>
<HeaderStyle Font-Name="Arial" Font-Size="9pt" Font-Bold="true" BackColor ="#003366" ForeColor ="#FFFFFF"/>
<AlternatingItemStyle Font-Name ="Arial" Font-Size ="9pt" BackColor ="#CCCCCC"/>
<columns>
<asp:boundColumn DataField="Item_Number" HeaderText="Item Number"/>
<asp:boundColumn DataField="Short_Description" HeaderText="Short Description"/>
<asp:boundColumn DataField="Long_Description" HeaderText="Long Description"/>
<asp:boundColumn DataField="Unit_Name" HeaderText="Unit Name"/>
<asp:boundColumn DataField="Plan_Unit_Description" HeaderText=" Plan Unit Description"/>
</columns>
</asp
</form>
</table>
</Body>
</Html>