我在运行我的aspx文件时遇到此错误,当我从下拉列表中选择开始和结束日期和值后单击按钮2。 该网站正常运作,但现在它正在抛出这个例外。 我的Aspx代码如下
<center><p style="color: #000000; font-weight: bold;">
START DATE AND TIME <asp:TextBox ID="TextBox3" runat="server" Width="181px" BorderColor="Black" BorderStyle="Solid"></asp:TextBox> <img src="calender.png" /></p></center>
<center> <p style="color: #000000; font-weight: bold;">
END DATE AND TIME <asp:TextBox ID="TextBox2" runat="server" Width="188px" BorderColor="Black" BorderStyle="Solid"></asp:TextBox> <img src="calender.png" />
</p>
</center>
<br />
<center style="height: 40px"> <asp:Button ID="Button2" runat="server" Text="SUBMIT AND CALCULATE" onclick="btnSave_Click1" BackColor="#FF9966" CssClass="btn btn-large" Font-Bold="True"/>
<br />
<td>
<asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False" CellPadding="3" DataSourceID="SqlDataSource5" Height="146px" Width="53px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
<Columns>
<asp:BoundField DataField="stdev_POLQA_score" HeaderText="stdev_POLQA_score" ReadOnly="True" SortExpression="stdev_POLQA_score" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView></td></tr></table>
<br />
<asp:Button ID="Button4" runat="server" BackColor="#FF9966" Text="EXPORT POLQA TO EXCEL" CssClass="btn btn-large" Font-Bold="True" />
<br />
<br />
<table><tr> <td>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource3" Height="146px" Width="53px" ForeColor="Black" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="mean_RTD" HeaderText="mean_RTD" ReadOnly="True" SortExpression="mean_RTD" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="White" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView></td>
<br /><td>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource4" Height="146px" Width="53px" ForeColor="Black" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="STDEV_RTD" HeaderText="stdev_RTD" ReadOnly="True" SortExpression="STDEV_RTD" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="White" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView></td>
<br />
</tr> </table>
</center>
<br />
<center> <asp:Button ID="Button3" runat="server" Text="EXPORT RTD TO EXCEL" onclick="Button3_Click" BackColor="#FF9966" CssClass="btn btn-large" Font-Bold="True" Width="257px"/>
</center>
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(AVG(POLQA_Score),3) AS mean_POLQA_score FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(AVG(RTD),3) AS mean_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT * FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuadPhone_ID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(Stdev(RTD),3) AS STDEV_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND? AND RTD>0 AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT * FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(Stdev(POLQA_score),3) AS stdev_POLQA_score FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<div style="display:none" ><center> <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource6" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="VQT_Timestamp" HeaderText="VQT_Timestamp" SortExpression="VQT_Timestamp" />
<asp:BoundField DataField="VQuad_Timestamp" HeaderText="VQuad_Timestamp" SortExpression="VQuad_Timestamp" />
<asp:BoundField DataField="GPS_Position" HeaderText="GPS_Position" SortExpression="GPS_Position" />
<asp:BoundField DataField="GPS_Lat" HeaderText="GPS_Lat" SortExpression="GPS_Lat" />
<asp:BoundField DataField="GPS_Long" HeaderText="GPS_Long" SortExpression="GPS_Long" />
<asp:BoundField DataField="VQuad_CallID" HeaderText="VQuad_CallID" SortExpression="VQuad_CallID" />
<asp:BoundField DataField="VQuad_Location" HeaderText="VQuad_Location" SortExpression="VQuad_Location" />
<asp:BoundField DataField="VQuad_PhoneID" HeaderText="VQuad_PhoneID" SortExpression="VQuad_PhoneID" />
<asp:BoundField DataField="Degraded" HeaderText="Degraded" SortExpression="Degraded" />
<asp:BoundField DataField="Deg_File_Name" HeaderText="Deg_File_Name" SortExpression="Deg_File_Name" />
<asp:BoundField DataField="POLQA_Score" HeaderText="POLQA_Score" SortExpression="POLQA_Score" />
<asp:BoundField DataField="Pass_Or_Fail" HeaderText="Pass_Or_Fail" SortExpression="Pass_Or_Fail" />
<asp:BoundField DataField="Jitter_Min" HeaderText="Jitter_Min" SortExpression="Jitter_Min" />
<asp:BoundField DataField="Jitter_Max" HeaderText="Jitter_Max" SortExpression="Jitter_Max" />
<asp:BoundField DataField="Jitter_Ave" HeaderText="Jitter_Ave" SortExpression="Jitter_Ave" />
<asp:BoundField DataField="EModel_Polqa" HeaderText="EModel_Polqa" SortExpression="EModel_Polqa" />
<asp:BoundField DataField="Speech_Level_Diff" HeaderText="Speech_Level_Diff" SortExpression="Speech_Level_Diff" />
<asp:BoundField DataField="SNR_Diff" HeaderText="SNR_Diff" SortExpression="SNR_Diff" />
<asp:BoundField DataField="ASR_Ref" HeaderText="ASR_Ref" SortExpression="ASR_Ref" />
<asp:BoundField DataField="ASR_Deg" HeaderText="ASR_Deg" SortExpression="ASR_Deg" />
<asp:BoundField DataField="Number_of_Utterance" HeaderText="Number_of_Utterance" SortExpression="Number_of_Utterance" />
<asp:BoundField DataField="Call_Timestamp" HeaderText="Call_Timestamp" SortExpression="Call_Timestamp" />
<asp:BoundField DataField="CallType_Orig" HeaderText="CallType_Orig" SortExpression="CallType_Orig" />
<asp:BoundField DataField="CallType_Term" HeaderText="CallType_Term" SortExpression="CallType_Term" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView></center></div>
<br />
<div style="display:none"><center><asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource7">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="VQuad_Timestamp" HeaderText="VQuad_Timestamp" SortExpression="VQuad_Timestamp" />
<asp:BoundField DataField="GPS_Position" HeaderText="GPS_Position" SortExpression="GPS_Position" />
<asp:BoundField DataField="GPS_Lat" HeaderText="GPS_Lat" SortExpression="GPS_Lat" />
<asp:BoundField DataField="GPS_Long" HeaderText="GPS_Long" SortExpression="GPS_Long" />
<asp:BoundField DataField="AFT" HeaderText="AFT" SortExpression="AFT" />
<asp:BoundField DataField="RTD" HeaderText="RTD" SortExpression="RTD" />
<asp:BoundField DataField="RTD_Error" HeaderText="RTD_Error" SortExpression="RTD_Error" />
<asp:BoundField DataField="PDD" HeaderText="PDD" SortExpression="PDD" />
<asp:BoundField DataField="PDD_Error" HeaderText="PDD_Error" SortExpression="PDD_Error" />
<asp:BoundField DataField="Phone_ID" HeaderText="Phone_ID" SortExpression="Phone_ID" />
<asp:BoundField DataField="Call_Control_Event" HeaderText="Call_Control_Event" SortExpression="Call_Control_Event" />
<asp:BoundField DataField="VQuad_CallID" HeaderText="VQuad_CallID" SortExpression="VQuad_CallID" />
<asp:BoundField DataField="VQuad_Location" HeaderText="VQuad_Location" SortExpression="VQuad_Location" />
<asp:BoundField DataField="VQuad_PhoneID" HeaderText="VQuad_PhoneID" SortExpression="VQuad_PhoneID" />
<asp:BoundField DataField="Call_Timestamp" HeaderText="Call_Timestamp" SortExpression="Call_Timestamp" />
<asp:BoundField DataField="RTD_Rating" HeaderText="RTD_Rating" SortExpression="RTD_Rating" />
<asp:BoundField DataField="OWD" HeaderText="OWD" SortExpression="OWD" />
<asp:BoundField DataField="SWR" HeaderText="SWR" SortExpression="SWR" />
<asp:BoundField DataField="CC_Condition" HeaderText="CC_Condition" SortExpression="CC_Condition" />
<asp:BoundField DataField="CallType_Orig" HeaderText="CallType_Orig" SortExpression="CallType_Orig" />
<asp:BoundField DataField="CallType_Term" HeaderText="CallType_Term" SortExpression="CallType_Term" />
</Columns>
</asp:GridView></center></div>
<br />
<br />
<asp:AccessDataSource runat="server" DataFile="C:\Users\saishnib\Desktop\VQT DB LATEST ORIGINAL (copy)\New folder\VQT.mdb" SelectCommand="SELECT AVG(POLQA_Score) AS MEANPOLQA FROM VQTPOLQA WHERE (VQT_Timestamp BETWEEN ? AND ?)">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
</SelectParameters>
</asp:AccessDataSource>
<br />
<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT [VQuad_PhoneID] FROM [VQTPOLQA]"></asp:SqlDataSource>
<br />
我的aspx.vb代码如下
Protected Sub btnSave_Click1(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Dim connectionString As [String] = "Provider=Microsoft.ACE.OLEDB.12.0;Data" + " Source=C:\Users\saishnib\Desktop\VQT DB LATEST ORIGINAL (copy)\New folder\VQT.mdb"
Dim ds As New DataSet()
Dim conn As New OleDbConnection(connectionString)
conn.Open()
Dim cmd As New OleDbCommand("SELECT ROUND(AVG(POLQA_Score),3) AS MEANPOLQA FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?", conn)
Dim cmd2 As New OleDbCommand("SELECT ROUND(AVG(RTD),3) AS mean_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 AND VQuad_PhoneID=?", conn)
Dim cmd3 As New OleDbCommand("SELECT Stdev(RTD) AS STDEV_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 VQuad_PhoneID =?", conn)
Dim cmd4 As New OleDbCommand("SELECT Stdev(POLQA_Score) AS STDEV_POLQA FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? VQuad_PhoneID =?", conn)
Dim param As OleDbParameter
param = cmd.CreateParameter
param.OleDbType = OleDbType.Date
param.Value = DateTime.Parse(TextBox3.Text)
param.ParameterName = "@StartDate"
cmd.Parameters.Add(param)
Dim param1 As OleDbParameter
param1 = cmd.CreateParameter
param1.OleDbType = OleDbType.Date
param1.Value = DateTime.Parse(TextBox2.Text)
param1.ParameterName = "@EndDate"
cmd.Parameters.Add(param1)
GridView1.DataBind()
Dim param2 As OleDbParameter
param2 = cmd2.CreateParameter
param2.OleDbType = OleDbType.Date
param2.Value = DateTime.Parse(TextBox3.Text)
param2.ParameterName = "@StartDate"
cmd2.Parameters.Add(param2)
Dim param3 As OleDbParameter
param3 = cmd2.CreateParameter
param3.OleDbType = OleDbType.Date
param3.Value = DateTime.Parse(TextBox2.Text)
param3.ParameterName = "@EndDate"
cmd2.Parameters.Add(param3)
GridView2.DataBind()
Dim param4 As OleDbParameter
param4 = cmd3.CreateParameter
param4.OleDbType = OleDbType.Date
param4.Value = DateTime.Parse(TextBox3.Text)
param4.ParameterName = "@StartDate"
cmd3.Parameters.Add(param4)
Dim param5 As OleDbParameter
param5 = cmd3.CreateParameter
param5.OleDbType = OleDbType.Date
param5.Value = DateTime.Parse(TextBox2.Text)
param5.ParameterName = "@EndDate"
cmd3.Parameters.Add(param5)
GridView3.DataBind()
Dim param6 As OleDbParameter
param6 = cmd4.CreateParameter
param6.OleDbType = OleDbType.Date
param6.Value = DateTime.Parse(TextBox3.Text)
param6.ParameterName = "@StartDate"
cmd4.Parameters.Add(param6)
Dim param7 As OleDbParameter
param7 = cmd4.CreateParameter
param7.OleDbType = OleDbType.Date
param7.Value = DateTime.Parse(TextBox2.Text)
param7.ParameterName = "@EndDate"
cmd4.Parameters.Add(param7)
GridView4.DataBind()
conn.Close()
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView6.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
Return
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView5.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
End Class
答案 0 :(得分:0)
编辑附加到特定GridView的SQL DATA源后我们可以修改?通过使用理想的SQL查询来控制TextBox和DropDown的内容可以解决这个问题。