Getting "value is not defined" while inheriting a type

Posted by James Black on Stack Overflow See other posts from Stack Overflow or by James Black
Published on 2010-05-10T01:22:10Z Indexed on 2010/05/10 1:28 UTC
Read the original article Hit count: 368

Filed under:
|

I can't see what I am doing wrong, as the files are in the correct order. In this case it is:

  1. BaseDAO.fs
  2. CreateDatabase.fs

They are in the same namespace, but even when I had them in different modules, and opened the module in CreateDatabase the same error.

The error is:

Error   1   The value or constructor 'execNonQuery' is not defined  

I am trying to inherit BaseDAO and use a member that will be common to several files, and I don't see why I get the error above.

namespace RestaurantServiceDAO

open MySql.Data.MySqlClient

type BaseDAO() =
    let connString = @"Server=localhost;Database=mysql;Uid=root;Pwd=$$$$;"
    let conn = new  MySqlConnection(connString)

    member self.execNonQuery(sqlStr) =
        conn.Open()
        let comm = new MySqlCommand(sqlStr, conn, CommandTimeout = 10)
        comm.ExecuteNonQuery |> ignore
        comm.Dispose |> ignore

The type that does inherit is here, and execNonQuery is not defined.

namespace RestaurantServiceDAO

open MySql.Data.MySqlClient

type CreateDatabase() =
    inherit BaseDAO()

    let createRestaurantTable conn =
        execNonQuery "CREATE TABLE restaurant(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), cur_timestamp TIMESTAMP(8))"

© Stack Overflow or respective owner

Related posts about F#

Related posts about inheritance