Reputation: 75
I'm trying to create a connection to open a database over ODBC. I cannot figure out how to execute an objects member functions. The code:
let DbConnection = new System.Data.Odbc.OdbcConnection()
DbConnection.open
The errors I get are: Missing qualification after '.'
or sometimes: unexpected identifier in implementation file
Does anybody know what is wrong with my syntax?
Upvotes: 1
Views: 310
Reputation: 243041
I suppose you wanted something like this:
let dbConnection = new System.Data.Odbc.OdbcConnection()
dbConnection.Open()
The problems are:
F# is case sensitive so you need Open
rather than open
(also open
is a language keyword, so if you wanted to use it as a name, you'd have to write ``open``
- the double back-tick is a way to refer to reserved names)
Open
is a function, so if you want to call it you need to give it an argument. You can treat it as a function value too and write, say, let f = dbConnection.Open
I also changed your naming to use camelCase
for variables, which is the standard F# way
Upvotes: 4