C/ODBC and C#

Hi All, I need to connect C# to a Navision-Database via C/ODBC. When i try to fill the Dataset (with the Method .fill) i get an error (“The Driver does not support this Function”). I’ve searched for c/odbc ad C# and found some very old topics, but no one has answered to the questions. Has anyone solved this Problem? Or has anyone an idea? Thanks in advance. Regards, Frank

From personal experience, using ODBC via code is a real pain in the neck (Nothing works as you would expect and nothing is supported!!!). I think the ODBC driver is too crappy to support Datasets. The following C# code snippet does work. Its a webservice that queries Navision via ODBC and, given a reference, looks up an address. Hopefully this is useful. Obviously, change the DSNs and query string to match your own database. [WebMethod (Description="This Webservice Returns Address Data from Navision")] public string GetAddress(String JobNo) { String ReturnString = ""; String sConnString = "Dsn=nav"; System.Data.Odbc.OdbcConnection connection = new System.Data.Odbc.OdbcConnection(sConnString); connection.Open(); System.Text.StringBuilder strBuild = new System.Text.StringBuilder("SELECT Address,\"Address 2\","+ "City,County,\"Post Code\" FROM Job WHERE No_ = '%1'"); strBuild.Replace("%1",JobNo); OdbcCommand catCMD = new OdbcCommand(strBuild.ToString(), connection); System.Data.Odbc.OdbcDataReader Reader = catCMD.ExecuteReader(); while (Reader.Read()) { for(int i = 0; i < 5; i++) { ReturnString += Reader.GetString(i) + " "; } } connection.Close(); return ReturnString; } edd

Wouldn’t C/FRONT be a better solution?

Thanks for your answers Edward and David, Yes, C/Front would be a better solution, because i need to write data [:D] Regards, Frank

Exaclty why C/FRONT is better, C/FRONT’s write abilities are far better then ODBC.