jaquel / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Connection not open #171

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi

I am trying to use Daper with an ODBC driver to an Informix Standard Engine 
Database (needs must)

The odbc driver is Informix 3.5

Informix does not use named paramters, but uses ? as placeholders.

In addition our veriosn does not support VARCHAR.

Any how, I have got Daper working with Select, and Inserts with composed sql 
strings, but want to use parameters to avoid potentai injection attacks etc.

Below is my code.

When using paramers I receive an error

 ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.

private IDbConnection conn = new OdbcConnection( 
ConfigurationManager.ConnectionStrings["test_connection"].ToString() );       
        public ActionResult Index()
        {

            string id = "SMI002";
            var sql =
                "INSERT INTO mjw_test (ten_ref) VALUES ( ? )";
            conn.Execute(sql, new[] { new DbString{IsFixedLength=true, Value="1234" }});

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
Draper 4.0
Windows 7 

Thanks

Michael

Original issue reported on code.google.com by michaelw...@gmail.com on 12 Mar 2014 at 11:04

GoogleCodeExporter commented 9 years ago
you are missing conn.Open() before using dapper. The exception message is clear 
about that.

Original comment by thomas.b...@gmail.com on 1 May 2014 at 3:48