Runtime Error

Discussion in 'ASP .Net' started by Bill Patel, Nov 23, 2004.

  1. Bill Patel

    Bill Patel Guest

    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 <ASP:DataGrid 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>
     
    Bill Patel, Nov 23, 2004
    #1
    1. Advertising

  2. Bill Patel

    Teemu Keiski Guest

    On line 46 you have:

    Dim Comm2 AS SqlDataAdapter

    e.g you don't instantiate the SqlDataAdapter at all (should be: Dim Comm2
    AS New SqlDataAdapter ) . You do instantiate it on previous line 45, but
    that is commented (you seem to use SqlCommand instead and set parameters etc
    via it). Just instantiate the SqlDataAdapter and it should work.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsider
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Bill Patel" <> wrote in message
    news:%...
    > 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 <ASP:DataGrid 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>
    >
    >
     
    Teemu Keiski, Nov 23, 2004
    #2
    1. Advertising

  3. Bill Patel

    Bill Patel Guest

    Teemu, thanks for replying. I am new programmer to asp.net. Still receive
    the Runtime Error. I have change code from line 45 to 48. Please make
    suggestion in what i programming wrong.

    > > 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 Dim Comm2 AS SqlDataAdapter
    > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > 47 Comm2.SelectCommand.Parameters.Add("@u_key",

    DS1.Tables(0).Rows(i).item(0).value)
    > > 48 Dim cb As SqlCommandBuilder = New

    SqlCommandBuilder(Comm2)
    > > 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 <ASP:DataGrid 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>


    "Teemu Keiski" <> wrote in message
    news:uN%...
    > On line 46 you have:
    >
    > Dim Comm2 AS SqlDataAdapter
    >
    > e.g you don't instantiate the SqlDataAdapter at all (should be: Dim Comm2
    > AS New SqlDataAdapter ) . You do instantiate it on previous line 45, but
    > that is commented (you seem to use SqlCommand instead and set parameters

    etc
    > via it). Just instantiate the SqlDataAdapter and it should work.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsider
    > ASP.NET Forum Moderator, AspAlliance Columnist
    > http://blogs.aspadvice.com/joteke
    >
    >
    > "Bill Patel" <> wrote in message
    > news:%...
    > > 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 <ASP:DataGrid 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>
    > >
    > >

    >
    >
     
    Bill Patel, Nov 23, 2004
    #3
  4. Bill Patel

    Jeff Dillon Guest

    What do you mean "change code from line 45 to 48"

    You still have

    45 Dim Comm2 AS SqlDataAdapter
    > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)


    Line 45 should be

    Dim Comm2 as New SQLDataAdapter

    "Bill Patel" <> wrote in message
    news:#...
    > Teemu, thanks for replying. I am new programmer to asp.net. Still receive
    > the Runtime Error. I have change code from line 45 to 48. Please make
    > suggestion in what i programming wrong.
    >
    > > > 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 Dim Comm2 AS SqlDataAdapter
    > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > > 47 Comm2.SelectCommand.Parameters.Add("@u_key",

    > DS1.Tables(0).Rows(i).item(0).value)
    > > > 48 Dim cb As SqlCommandBuilder = New

    > SqlCommandBuilder(Comm2)
    > > > 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 <ASP:DataGrid 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>

    >
    > "Teemu Keiski" <> wrote in message
    > news:uN%...
    > > On line 46 you have:
    > >
    > > Dim Comm2 AS SqlDataAdapter
    > >
    > > e.g you don't instantiate the SqlDataAdapter at all (should be: Dim

    Comm2
    > > AS New SqlDataAdapter ) . You do instantiate it on previous line 45, but
    > > that is commented (you seem to use SqlCommand instead and set parameters

    > etc
    > > via it). Just instantiate the SqlDataAdapter and it should work.
    > >
    > > --
    > > Teemu Keiski
    > > MCP, Microsoft MVP (ASP.NET), AspInsider
    > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > http://blogs.aspadvice.com/joteke
    > >
    > >
    > > "Bill Patel" <> wrote in message
    > > news:%...
    > > > 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 <ASP:DataGrid 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>
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jeff Dillon, Nov 23, 2004
    #4
  5. Bill Patel

    Bill Patel Guest

    I did change line 45 to Dim Comm2 as New SQLDataAdapter. Runtime error still
    shows.


    "Jeff Dillon" <> wrote in message
    news:...
    > What do you mean "change code from line 45 to 48"
    >
    > You still have
    >
    > 45 Dim Comm2 AS SqlDataAdapter
    > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)

    >
    > Line 45 should be
    >
    > Dim Comm2 as New SQLDataAdapter
    >
    > "Bill Patel" <> wrote in message
    > news:#...
    > > Teemu, thanks for replying. I am new programmer to asp.net. Still

    receive
    > > the Runtime Error. I have change code from line 45 to 48. Please make
    > > suggestion in what i programming wrong.
    > >
    > > > > 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 Dim Comm2 AS SqlDataAdapter
    > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > > > 47 Comm2.SelectCommand.Parameters.Add("@u_key",

    > > DS1.Tables(0).Rows(i).item(0).value)
    > > > > 48 Dim cb As SqlCommandBuilder = New

    > > SqlCommandBuilder(Comm2)
    > > > > 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 <ASP:DataGrid 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>

    > >
    > > "Teemu Keiski" <> wrote in message
    > > news:uN%...
    > > > On line 46 you have:
    > > >
    > > > Dim Comm2 AS SqlDataAdapter
    > > >
    > > > e.g you don't instantiate the SqlDataAdapter at all (should be: Dim

    > Comm2
    > > > AS New SqlDataAdapter ) . You do instantiate it on previous line 45,

    but
    > > > that is commented (you seem to use SqlCommand instead and set

    parameters
    > > etc
    > > > via it). Just instantiate the SqlDataAdapter and it should work.
    > > >
    > > > --
    > > > Teemu Keiski
    > > > MCP, Microsoft MVP (ASP.NET), AspInsider
    > > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > > http://blogs.aspadvice.com/joteke
    > > >
    > > >
    > > > "Bill Patel" <> wrote in message
    > > > news:%...
    > > > > 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 <ASP:DataGrid 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>
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Bill Patel, Nov 23, 2004
    #5
  6. Bill Patel

    Jeff Dillon Guest

    The code you included again didn't show your change..

    Jeff

    "Bill Patel" <> wrote in message
    news:...
    > I did change line 45 to Dim Comm2 as New SQLDataAdapter. Runtime error

    still
    > shows.
    >
    >
    > "Jeff Dillon" <> wrote in message
    > news:...
    > > What do you mean "change code from line 45 to 48"
    > >
    > > You still have
    > >
    > > 45 Dim Comm2 AS SqlDataAdapter
    > > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)

    > >
    > > Line 45 should be
    > >
    > > Dim Comm2 as New SQLDataAdapter
    > >
    > > "Bill Patel" <> wrote in message
    > > news:#...
    > > > Teemu, thanks for replying. I am new programmer to asp.net. Still

    > receive
    > > > the Runtime Error. I have change code from line 45 to 48. Please make
    > > > suggestion in what i programming wrong.
    > > >
    > > > > > 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 Dim Comm2 AS SqlDataAdapter
    > > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > > > > 47 Comm2.SelectCommand.Parameters.Add("@u_key",
    > > > DS1.Tables(0).Rows(i).item(0).value)
    > > > > > 48 Dim cb As SqlCommandBuilder = New
    > > > SqlCommandBuilder(Comm2)
    > > > > > 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 <ASP:DataGrid 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>
    > > >
    > > > "Teemu Keiski" <> wrote in message
    > > > news:uN%...
    > > > > On line 46 you have:
    > > > >
    > > > > Dim Comm2 AS SqlDataAdapter
    > > > >
    > > > > e.g you don't instantiate the SqlDataAdapter at all (should be: Dim

    > > Comm2
    > > > > AS New SqlDataAdapter ) . You do instantiate it on previous line 45,

    > but
    > > > > that is commented (you seem to use SqlCommand instead and set

    > parameters
    > > > etc
    > > > > via it). Just instantiate the SqlDataAdapter and it should work.
    > > > >
    > > > > --
    > > > > Teemu Keiski
    > > > > MCP, Microsoft MVP (ASP.NET), AspInsider
    > > > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > > > http://blogs.aspadvice.com/joteke
    > > > >
    > > > >
    > > > > "Bill Patel" <> wrote in message
    > > > > news:%...
    > > > > > 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 <ASP:DataGrid 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>
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jeff Dillon, Nov 24, 2004
    #6
  7. Bill Patel

    Bill Patel Guest

    I have the code working.

    "Jeff Dillon" <> wrote in message
    news:%...
    > The code you included again didn't show your change..
    >
    > Jeff
    >
    > "Bill Patel" <> wrote in message
    > news:...
    > > I did change line 45 to Dim Comm2 as New SQLDataAdapter. Runtime error

    > still
    > > shows.
    > >
    > >
    > > "Jeff Dillon" <> wrote in message
    > > news:...
    > > > What do you mean "change code from line 45 to 48"
    > > >
    > > > You still have
    > > >
    > > > 45 Dim Comm2 AS SqlDataAdapter
    > > > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > >
    > > > Line 45 should be
    > > >
    > > > Dim Comm2 as New SQLDataAdapter
    > > >
    > > > "Bill Patel" <> wrote in message
    > > > news:#...
    > > > > Teemu, thanks for replying. I am new programmer to asp.net. Still

    > > receive
    > > > > the Runtime Error. I have change code from line 45 to 48. Please

    make
    > > > > suggestion in what i programming wrong.
    > > > >
    > > > > > > 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 Dim Comm2 AS SqlDataAdapter
    > > > > > > 46 Comm2.SelectCommand = New SqlCommand(QS1, Conn1)
    > > > > > > 47 Comm2.SelectCommand.Parameters.Add("@u_key",
    > > > > DS1.Tables(0).Rows(i).item(0).value)
    > > > > > > 48 Dim cb As SqlCommandBuilder = New
    > > > > SqlCommandBuilder(Comm2)
    > > > > > > 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 <ASP:DataGrid 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>
    > > > >
    > > > > "Teemu Keiski" <> wrote in message
    > > > > news:uN%...
    > > > > > On line 46 you have:
    > > > > >
    > > > > > Dim Comm2 AS SqlDataAdapter
    > > > > >
    > > > > > e.g you don't instantiate the SqlDataAdapter at all (should be:

    Dim
    > > > Comm2
    > > > > > AS New SqlDataAdapter ) . You do instantiate it on previous line

    45,
    > > but
    > > > > > that is commented (you seem to use SqlCommand instead and set

    > > parameters
    > > > > etc
    > > > > > via it). Just instantiate the SqlDataAdapter and it should work.
    > > > > >
    > > > > > --
    > > > > > Teemu Keiski
    > > > > > MCP, Microsoft MVP (ASP.NET), AspInsider
    > > > > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > > > > http://blogs.aspadvice.com/joteke
    > > > > >
    > > > > >
    > > > > > "Bill Patel" <> wrote in message
    > > > > > news:%...
    > > > > > > 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 <ASP:DataGrid 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>
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Bill Patel, Nov 24, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Polo Lee
    Replies:
    0
    Views:
    2,732
    Polo Lee
    Jul 7, 2003
  2. Yongsub Eric Shin
    Replies:
    7
    Views:
    864
    Martin
    Jan 14, 2004
  3. Kevin Farless
    Replies:
    13
    Views:
    15,227
    chesterchass
    Oct 3, 2007
  4. Krunom Ancini
    Replies:
    2
    Views:
    5,169
  5. Hal Vaughan
    Replies:
    11
    Views:
    1,119
    Gordon Beaton
    May 22, 2006
Loading...

Share This Page