Re: .net, parameters and ms enterprise library
Posted in 2008
Topics: General Discussion
Ok, revived the enterprise library from the ditch... This one works good as well.... So now I wonder... the '?' thing... is a requirement from who? The informix driver? Or the DB itself? Console.WriteLine("Test Parameter"); Console.WriteLine("==========================="); Database db = DatabaseFactory.CreateDatabase(_cmecfDatabaseName); try { string sqlCommand = "SELECT * FROM USERS WHERE PRID = ?;"; DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand); int prid = 386; db.AddInParameter(dbCommand, "prid", DbType.Int32, prid); DataSet ds = db.ExecuteDataSet(dbCommand); Console.WriteLine(String.Format("Username = {0}", ds.Tables[0].Rows[0]["name"])); } catch (Exception ex) { Console.WriteLine(ex.Message); }
As already noted before, that is from the database, it is the standard SQL replaceable parameter marker. Art On Thu, Jun 19, 2008 at 3:08 PM, Padu <pmerloti@gmail.com> wrote: > Ok, revived the enterprise library from the ditch... > > This one works good as well.... > > So now I wonder... the '?' thing... is a requirement from who? The > informix driver? Or the DB itself? > > Console.WriteLine("Test Parameter"); > Console.WriteLine("==========================="); > > Database db = > DatabaseFactory.CreateDatabase(_cmecfDatabaseName); > > try > { > string sqlCommand = "SELECT * FROM USERS WHERE PRID > = ?;"; > DbCommand dbCommand = > db.GetSqlStringCommand(sqlCommand); > > int prid = 386; > db.AddInParameter(dbCommand, "prid", DbType.Int32, > prid); > > DataSet ds = db.ExecuteDataSet(dbCommand); > > Console.WriteLine(String.Format("Username = {0}", > ds.Tables[0].Rows[0]["name"])); > } > catch (Exception ex) > { > Console.WriteLine(ex.Message); > } > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list > -- Art S. Kagel Oninit (www.oninit.com) IIUG Board of Directors (art@iiug.org) Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Oninit, the IIUG, nor any other organization with which I am associated either explicitly or implicitly. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves.