Databind

2003-04-10
2003-06-12
  • Jose Arvelo
    Jose Arvelo
    2003-04-10

    What am I doing wrong?
    I get the following error message:
    Type: 'MySQLDriverCS.MySQLDataReader' has no constructors.
    For the source error it highlights line 15 where I dim db_datareader as new mySQLDatareader

    <code>

    <%@ Page Language="VB" Debug="true" CompilerOptions='/R:"C:\Program Files\MySQLDriverCS\dll\MySQLDriverCS.dll"'  %>

    <%@ import Namespace="System" %>

    <%@ import Namespace="MySQLDriverCS" %>

    <script runat="server">

        Dim db_mySQLConn as MySQLConnection = new MySQLConnection(new MySQLConnectionString("localhost","vcbmatrix","root","").AsString)

       

        Sub Page_Load(sender as Object, e as EventArgs)

            mySQLbind()

        end sub

        sub mySQLbind()

            dim strSQL as string = "select * from employees;"

            dim db_sqlCommand as new mySQLCommand(strSQL, db_MySQLConn)

            db_mySQLConn.open

            dim db_sqlReader as new mySQLDatareader

            db_sqlReader = db_sqlCommand.executereader

       

            dgEmployees.datasource = db_sqlReader

            dgEmployees.databind()

            db_mySQLConn.close

        end sub

    </script>

    <%@ import Namespace="MySQLDriverCS" %>

    <html>

    <head>

    </head>

    <body>

        <form runat="server">

            <asp:Label id="lblConnectionStatus" runat="server" Width="511px">Label</asp:Label>

            <asp:DataGrid id="dgEmployees" runat="server"></asp:DataGrid>

        </form>

    </body>

    </html>

    </code>

    Any input is greatly appreciated.

     

    • Anonymous
      2003-06-11

      You probably know this by now but the reader should be referred like this:
        dim db_sqlReader = db_sqlCommand.executereader

      instead of:
        dim db_sqlReader as new mySQLDatareader
        db_sqlReader = db_sqlCommand.executereader

      :-)

       

    • Anonymous
      2003-06-11

      ...or so I figure, since I have never used VB.NET but only C# coming from the Java world...

      In C# it would be:
      mySQLDataReader myReader = db_sqlCommand.ExecuteReader();

      Just in case the first post was bullshit to you VB folks out there...

       
    • Sven Dummis
      Sven Dummis
      2003-06-12

      The Datareader needs to be reffered in VB.NET like this:

      dim db_sqlReader as mySQLDatareader

      db_sqlReader = db_sqlCommand.executereader

      The NEW you can only use if there is a constructor in the class. The MySqlDataReader doesn't have one. The DataReader will be "constructed" by calling MySQLCommand.executeReader() or MySQLCommand.executeReaderEx()