Getting "value is not defined" while inheriting a type
- by James Black
I can't see what I am doing wrong, as the files are in the correct order. In this case it is:
BaseDAO.fs
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))"