BC30456: 'HasRows' is not a member of 'System.Data.SqlClient.SqlDataReader'.

Discussion in 'ASP .Net' started by TN Bella, Jun 19, 2004.

  1. TN Bella

    TN Bella Guest

    PLEASE HELP!! I am so far behind....and it doesn't help that I am
    learning all this stuff. I am using .net framework 1.0 from WebMatrix.
    These parameters get me all confused...someone please help! Thanks in
    advance for the assistance.



    Line 18: MyConn.Open()
    Line 19:
    objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    Line 20: if objDR.HasRows then
    Line 21: blHasRows="True"
    Line 22: else



    <%@ Page Language="VB" Debug="true" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.SQLClient" %>
    <script runat="server">

    Dim blHasRows as Boolean
    Sub doInsert(Source as Object, E as EventArgs)
    Dim strConn as string =
    "server=abcd;database:cds;trusted_connection=true"
    Dim MySQL as string = "Select supplier_cd, inv_no, inv_date from
    view_cds_all where supplier_cd=@supcd,inv_no=@invnum, inv_date=@invdat"
    Dim MyConn as New SQLConnection(strConn)
    Dim objDR as SQLDataReader
    Dim Cmd as New SQLCommand(MySQL, MyConn)
    With Cmd.Parameters
    .Add(New SQLParameter("@supcd", frmsupcd.text))
    .Add(New SQLParameter("@invnum", frminvnum.text))
    .Add(New SQLParameter("@invdat", frminvdat.text))
    End With
    MyConn.Open()
    objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    if objDR.HasRows then
    blHasRows="True"
    else
    blHasRows="False"
    End If
    MyConn.Close()
    MySQL = "Insert into ap_vendors.dbo.tbl_ap_web_ce_inv_terms
    (supcd, invnum, invdat) Values (@supcd, @invnum, @invdat)"
    Dim Cmd2 as New SQLCommand(MySQL, MyConn)
    With Cmd2.Parameters
    .Add(New SQLParameter("@supcd", frmsupcd.text))
    .Add(New SQLParameter("@invnum", frminvnum.text))
    .Add(New SQLParameter("@invdat", frminvdat.text))
    End With
    if blHasRows="False" then
    MyConn.Open()
    cmd2.ExecuteNonQuery()
    lblResults.text="Your information has been received!"
    MyConn.Close
    seeRecords()
    else
    lblResults.text="Sorry, that information is already in
    the database"
    End If
    End Sub

    Sub Page_Load(Source as Object, E as EventArgs)

    End Sub

    Sub seeRecords()
    Dim strConn as string = "server=abcd;database=ap_vendors"
    Dim MySQL as string = "Select * from tbl_ap_web_ce_inv_terms order
    by splr_cd"
    Dim MyConn as New SQLConnection(strConn)
    Dim objDR as SQLDataReader
    Dim Cmd as New SQLCommand(MySQL, MyConn)
    With Cmd.Parameters
    .Add(New SQLParameter("@supcd", frmsupcd.text))
    .Add(New SQLParameter("@invnum", frminvnum.text))
    .Add(New SQLParameter("@invdat", frminvdat.text))
    End With
    MyConn.Open()
    objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    MyDataGrid.DataSource=objDR
    MyDataGrid.DataBind
    MyConn.Close()
    End Sub

    </script>
    <html>
    <head>
    <title>Checking Data before Inserting New Data</title>
    <meta content="ASP Express 3.2" name="GENERATOR" />
    </head>
    <body>
    <form id="form1" runat="server">
    <div align="center">
    <table>
    <tbody>
    <tr>
    <td align="right">
    Title</td>
    <td>
    <asp:textbox id="frmsupcd" Runat="server"
    Text="Supplier Code"></asp:textbox>
    </td>
    </tr>
    <tr>
    <td align="right">
    Link</td>
    <td>
    <asp:textbox id="frminvnum" Runat="server"
    Text="invoice number"></asp:textbox>
    </td>
    </tr>
    <tr>
    <td align="right">
    Description</td>
    <td>
    <asp:textbox id="frminvdat"
    Runat="server"></asp:textbox>
    </td>
    </tr>
    <tr>
    <td align="right">
    <asp:button id="button1" onclick="doInsert"
    Runat="server" Text="Submit"></asp:button>
    </td>
    <td>
    </td>
    </tr>
    </tbody>
    </table>
    <asp:Label id="lblResults" runat="server"
    font-bold="True"></asp:Label>
    <asp:Datagrid id="MyDataGrid" Runat="server"
    BorderColor="Black" Font-Size="8" Font-Name="Arial" BackColor="#E7EFFF"
    Headerstyle-Font-Size="8" Headerstyle-Font-Name="Arial"
    Headerstyle-BackColor="#BDCFE7" cellspacing="0" cellpadding="0"
    GridLines="Both"></asp:Datagrid>
    </div>
    </form>
    </body>
    </html>


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    TN Bella, Jun 19, 2004
    #1
    1. Advertising

  2. Hi,

    check what version of the framework you're running, in the .NET Framework
    reference I saw the following sentence:

    Note: This namespace, class, or member is supported only in version 1.1 of
    the .NET Framework.

    Hope this helps
    Cheers
    Cristian



    "TN Bella" <> wrote in message
    news:%23$...
    >
    >
    > PLEASE HELP!! I am so far behind....and it doesn't help that I am
    > learning all this stuff. I am using .net framework 1.0 from WebMatrix.
    > These parameters get me all confused...someone please help! Thanks in
    > advance for the assistance.
    >
    >
    >
    > Line 18: MyConn.Open()
    > Line 19:
    > objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    > Line 20: if objDR.HasRows then
    > Line 21: blHasRows="True"
    > Line 22: else
    >
    >
    >
    > <%@ Page Language="VB" Debug="true" %>
    > <%@ import Namespace="System.Data" %>
    > <%@ import Namespace="System.Data.SQLClient" %>
    > <script runat="server">
    >
    > Dim blHasRows as Boolean
    > Sub doInsert(Source as Object, E as EventArgs)
    > Dim strConn as string =
    > "server=abcd;database:cds;trusted_connection=true"
    > Dim MySQL as string = "Select supplier_cd, inv_no, inv_date from
    > view_cds_all where supplier_cd=@supcd,inv_no=@invnum, inv_date=@invdat"
    > Dim MyConn as New SQLConnection(strConn)
    > Dim objDR as SQLDataReader
    > Dim Cmd as New SQLCommand(MySQL, MyConn)
    > With Cmd.Parameters
    > .Add(New SQLParameter("@supcd", frmsupcd.text))
    > .Add(New SQLParameter("@invnum", frminvnum.text))
    > .Add(New SQLParameter("@invdat", frminvdat.text))
    > End With
    > MyConn.Open()
    > objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    > if objDR.HasRows then
    > blHasRows="True"
    > else
    > blHasRows="False"
    > End If
    > MyConn.Close()
    > MySQL = "Insert into ap_vendors.dbo.tbl_ap_web_ce_inv_terms
    > (supcd, invnum, invdat) Values (@supcd, @invnum, @invdat)"
    > Dim Cmd2 as New SQLCommand(MySQL, MyConn)
    > With Cmd2.Parameters
    > .Add(New SQLParameter("@supcd", frmsupcd.text))
    > .Add(New SQLParameter("@invnum", frminvnum.text))
    > .Add(New SQLParameter("@invdat", frminvdat.text))
    > End With
    > if blHasRows="False" then
    > MyConn.Open()
    > cmd2.ExecuteNonQuery()
    > lblResults.text="Your information has been received!"
    > MyConn.Close
    > seeRecords()
    > else
    > lblResults.text="Sorry, that information is already in
    > the database"
    > End If
    > End Sub
    >
    > Sub Page_Load(Source as Object, E as EventArgs)
    >
    > End Sub
    >
    > Sub seeRecords()
    > Dim strConn as string = "server=abcd;database=ap_vendors"
    > Dim MySQL as string = "Select * from tbl_ap_web_ce_inv_terms order
    > by splr_cd"
    > Dim MyConn as New SQLConnection(strConn)
    > Dim objDR as SQLDataReader
    > Dim Cmd as New SQLCommand(MySQL, MyConn)
    > With Cmd.Parameters
    > .Add(New SQLParameter("@supcd", frmsupcd.text))
    > .Add(New SQLParameter("@invnum", frminvnum.text))
    > .Add(New SQLParameter("@invdat", frminvdat.text))
    > End With
    > MyConn.Open()
    > objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    > MyDataGrid.DataSource=objDR
    > MyDataGrid.DataBind
    > MyConn.Close()
    > End Sub
    >
    > </script>
    > <html>
    > <head>
    > <title>Checking Data before Inserting New Data</title>
    > <meta content="ASP Express 3.2" name="GENERATOR" />
    > </head>
    > <body>
    > <form id="form1" runat="server">
    > <div align="center">
    > <table>
    > <tbody>
    > <tr>
    > <td align="right">
    > Title</td>
    > <td>
    > <asp:textbox id="frmsupcd" Runat="server"
    > Text="Supplier Code"></asp:textbox>
    > </td>
    > </tr>
    > <tr>
    > <td align="right">
    > Link</td>
    > <td>
    > <asp:textbox id="frminvnum" Runat="server"
    > Text="invoice number"></asp:textbox>
    > </td>
    > </tr>
    > <tr>
    > <td align="right">
    > Description</td>
    > <td>
    > <asp:textbox id="frminvdat"
    > Runat="server"></asp:textbox>
    > </td>
    > </tr>
    > <tr>
    > <td align="right">
    > <asp:button id="button1" onclick="doInsert"
    > Runat="server" Text="Submit"></asp:button>
    > </td>
    > <td>
    > </td>
    > </tr>
    > </tbody>
    > </table>
    > <asp:Label id="lblResults" runat="server"
    > font-bold="True"></asp:Label>
    > <asp:Datagrid id="MyDataGrid" Runat="server"
    > BorderColor="Black" Font-Size="8" Font-Name="Arial" BackColor="#E7EFFF"
    > Headerstyle-Font-Size="8" Headerstyle-Font-Name="Arial"
    > Headerstyle-BackColor="#BDCFE7" cellspacing="0" cellpadding="0"
    > GridLines="Both"></asp:Datagrid>
    > </div>
    > </form>
    > </body>
    > </html>
    >
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Cristian Suazo, Jun 19, 2004
    #2
    1. Advertising

  3. TN Bella

    TN Bella Guest

    Thanks! After this project I am updating my .net framework!! argh!
    Thanks again...I have to wait until Monday to see if I can fix the
    project.

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    TN Bella, Jun 20, 2004
    #3
    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. AJ

    sqldatareader.HasRows

    AJ, Nov 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,370
    Rob Meade
    Nov 18, 2003
  2. Zenobia
    Replies:
    1
    Views:
    7,220
    Zenobia
    Jul 6, 2004
  3. Stan
    Replies:
    0
    Views:
    590
  4. djc
    Replies:
    1
    Views:
    4,920
  5. Albert
    Replies:
    4
    Views:
    10,843
    Albert
    Jul 10, 2008
Loading...

Share This Page