B
Bill Patel
I am getting Runtime error on line 50. Please Help.
Thank You
Bill
1 <%@ Page Language="VB" %>
2 <%@ import Namespace="System.Data" %>
3 <%@ import Namespace="System.Data.SqlClient" %>
4 <script runat="server">
5
6 Sub Page_load(Src AS Object, e AS EventArgs)
7 Dim rightNowBegin as DateTime = DateTime.Now
8 lblDateBegin.Text = String.Format("{0:d}", rightNowBegin)
9 lblTimeBegin.Text = String.Format("{0:T}", rightNowBegin)
10
11 Dim Conn1 AS SqlConnection
12 Dim Comm1 AS SqlDataAdapter
13 Conn1 = new
SqlConnection("server=thales;uid=sa;pwd=36overhaul;database=reported")
14 Comm1 = new SqlDataAdapter("DELETE ClientLRDT", Conn1)
15 Comm1 = new SqlDataAdapter("DELETE ClientLRDFT", Conn1)
16 Comm1 = new SqlDataAdapter("SELECT u_key FROM Insured WHERE
status = 'IF' GROUP BY u_key ORDER BY u_key", Conn1)
17 Dim DS1 As DataSet = new DataSet()
18 Comm1.Fill(DS1)
19 DG1.DataSource = DS1
20 DG1.DataBind()
21
22 'Fill the RowCount Integer
23 Dim RowCount As Integer = DS1.Tables(0).Rows.Count
24
25 'Use the ToString() method to bind the row count to the Text
property of the label control.
26 'The Text property expects a string hence the ToString() method
is used.
27 countLabel.Text = RowCount.ToString()
28
29 Dim I AS Integer = 0
30 DO While I <= DS1.Tables(0).Rows.Count - 1
31 Dim cmdCore As String = ""
32 Dim sb As StringBuilder = New StringBuilder("")
33 sb.Append("SELECT insured.policy, insured.u_key,
insured.effective, insured.expiration, ")
34 sb.Append("insured.status, insured.audit ")
35 sb.Append("FROM insured ")
36 sb.Append("WHERE insured.u_key = @u_key ")
37 sb.Append("ORDER BY insured.u_key, insured.effective,
insured.expiration")
38 cmdCore = sb.ToString()
39 Dim QS1 As String = "SELECT insured.policy, insured.u_key,
insured.effective, insured.expiration, " & _
40 "insured.status, insured.audit " & _
41 "FROM insured " & _
42 "WHERE insured.u_key = @u_key " & _
43 "ORDER BY insured.u_key,
insured.effective, insured.expiration"
44
45 'Comm2 = new SqlDataAdapter(QS1, Conn1)
46 Dim Comm2 AS SqlDataAdapter
47 Comm2.SelectCommand = New SqlCommand(cmdCore, Conn1)
48 Comm2.SelectCommand.Parameters.Add("@u_key",
DS1.Tables(0).Rows(i).item(0).value)
49 Dim DS2 As DataSet = new DataSet()
50 Comm2.Fill(DS2)
51 countLabel.Text = cmdCore
52 I = I + 1
53 Loop
54
55 Dim rightNowEnd as DateTime = DateTime.Now
56 lblDateEnd.Text = String.Format("{0:d}", rightNowEnd)
57 lblTimeEnd.Text = String.Format("{0:T}", rightNowEnd)
58 End Sub
59
60 </script>
61 <html>
62 <head>
63 <title>Insured with Losses</title>
64 </head>
65 <body>
66 <ASPataGrid id="DG1" width="100%" Runat="Server" />
67 <asp:Label id="lblDateBegin" width="100%"
runat="Server"></asp:Label>
68 <asp:Label id="lblTimeBegin" width="100%"
runat="Server"></asp:Label>
69 <asp:Label id="countLabel" width="100%"
runat="Server"></asp:Label>
70 <asp:Label id="lblDateEnd" width="100%"
runat="Server"></asp:Label>
71 <asp:Label id="lblTimeEnd" width="100%"
runat="Server"></asp:Label>
72 </body>
73 </html>
Thank You
Bill
1 <%@ Page Language="VB" %>
2 <%@ import Namespace="System.Data" %>
3 <%@ import Namespace="System.Data.SqlClient" %>
4 <script runat="server">
5
6 Sub Page_load(Src AS Object, e AS EventArgs)
7 Dim rightNowBegin as DateTime = DateTime.Now
8 lblDateBegin.Text = String.Format("{0:d}", rightNowBegin)
9 lblTimeBegin.Text = String.Format("{0:T}", rightNowBegin)
10
11 Dim Conn1 AS SqlConnection
12 Dim Comm1 AS SqlDataAdapter
13 Conn1 = new
SqlConnection("server=thales;uid=sa;pwd=36overhaul;database=reported")
14 Comm1 = new SqlDataAdapter("DELETE ClientLRDT", Conn1)
15 Comm1 = new SqlDataAdapter("DELETE ClientLRDFT", Conn1)
16 Comm1 = new SqlDataAdapter("SELECT u_key FROM Insured WHERE
status = 'IF' GROUP BY u_key ORDER BY u_key", Conn1)
17 Dim DS1 As DataSet = new DataSet()
18 Comm1.Fill(DS1)
19 DG1.DataSource = DS1
20 DG1.DataBind()
21
22 'Fill the RowCount Integer
23 Dim RowCount As Integer = DS1.Tables(0).Rows.Count
24
25 'Use the ToString() method to bind the row count to the Text
property of the label control.
26 'The Text property expects a string hence the ToString() method
is used.
27 countLabel.Text = RowCount.ToString()
28
29 Dim I AS Integer = 0
30 DO While I <= DS1.Tables(0).Rows.Count - 1
31 Dim cmdCore As String = ""
32 Dim sb As StringBuilder = New StringBuilder("")
33 sb.Append("SELECT insured.policy, insured.u_key,
insured.effective, insured.expiration, ")
34 sb.Append("insured.status, insured.audit ")
35 sb.Append("FROM insured ")
36 sb.Append("WHERE insured.u_key = @u_key ")
37 sb.Append("ORDER BY insured.u_key, insured.effective,
insured.expiration")
38 cmdCore = sb.ToString()
39 Dim QS1 As String = "SELECT insured.policy, insured.u_key,
insured.effective, insured.expiration, " & _
40 "insured.status, insured.audit " & _
41 "FROM insured " & _
42 "WHERE insured.u_key = @u_key " & _
43 "ORDER BY insured.u_key,
insured.effective, insured.expiration"
44
45 'Comm2 = new SqlDataAdapter(QS1, Conn1)
46 Dim Comm2 AS SqlDataAdapter
47 Comm2.SelectCommand = New SqlCommand(cmdCore, Conn1)
48 Comm2.SelectCommand.Parameters.Add("@u_key",
DS1.Tables(0).Rows(i).item(0).value)
49 Dim DS2 As DataSet = new DataSet()
50 Comm2.Fill(DS2)
51 countLabel.Text = cmdCore
52 I = I + 1
53 Loop
54
55 Dim rightNowEnd as DateTime = DateTime.Now
56 lblDateEnd.Text = String.Format("{0:d}", rightNowEnd)
57 lblTimeEnd.Text = String.Format("{0:T}", rightNowEnd)
58 End Sub
59
60 </script>
61 <html>
62 <head>
63 <title>Insured with Losses</title>
64 </head>
65 <body>
66 <ASPataGrid id="DG1" width="100%" Runat="Server" />
67 <asp:Label id="lblDateBegin" width="100%"
runat="Server"></asp:Label>
68 <asp:Label id="lblTimeBegin" width="100%"
runat="Server"></asp:Label>
69 <asp:Label id="countLabel" width="100%"
runat="Server"></asp:Label>
70 <asp:Label id="lblDateEnd" width="100%"
runat="Server"></asp:Label>
71 <asp:Label id="lblTimeEnd" width="100%"
runat="Server"></asp:Label>
72 </body>
73 </html>