ODBC nightmare lazarus / 16-Databases ---------------------------------------------------------------------- Zath · 2016-05-15 21:28 I've read all sorts of examples on how to connect ODBC to MS SQL in Lazarus. I've even contemplated going back to D2007 and ADO because I had that working... Grrr. Can someone tell me in words of one syllable how to do it please ? Assume I have a form with an ODBCConnection, SQLQuery, SQLTransaction, DBEdit.  (do I need these or something else ?) Details are :- ZATH-PC\SQLEXPRESS user= abcd pwd= 1234 Database = LOM2Res Table name = Monsters Field = Fld_one Driver = ODBC Driver 11 for SQL Server What properties should I populate ? Many examples seem to want to populate the properties from code instead of within the component at design time. Why ? How do I connect to the table to get the DBedit to show Fld_one ? Thanks ---------------------------------------------------------------------- LacaK · 2016-05-16 05:21 Quote from: Zath on May 15, 2016, 11:28:38 pmWhat properties should I populate ? Many examples seem to want to populate the properties from code instead of within the component at design time. Why ? No problem set properties using form designer ... Try look at http://wiki.freepascal.org/ODBCConn ---------------------------------------------------------------------- Zath · 2016-05-16 07:54 Thanks Lacak. I've already been to that page before. Tried what was said and still failed. One of the links to the mssql option seems to go to a commercial site. I don't really want to buy anything. I will have another go and try the connectionstrings.com link. Might get something click differently this time. ---------------------------------------------------------------------- miab3 · 2016-05-16 08:37 Can you try ZEOS 7.3: https://sourceforge.net/p/zeoslib/code-0/HEAD/tree/branches/testing- 7.3/ Michal ---------------------------------------------------------------------- Zath · 2016-05-16 08:52 I've seen Zeos in the forum and considered it for an ADO connection. Is that what you're suggesting ? Do I go to packages/lazarus ? ---------------------------------------------------------------------- miab3 · 2016-05-16 12:31 I'm talking about ZEOS 7.3 and MSSQL ODBC and OleDB. Michal ---------------------------------------------------------------------- LacaK · 2016-05-16 12:55 In case of TODBCConnection there is important: DatabaseName which converts to DSN= UserName which converts to USR= Password which converts to PWD= in connection string ... So chceck these settings. ---------------------------------------------------------------------- eny · 2016-05-16 20:14 Quote from: LacaK on May 16, 2016, 02:55:47 pmIn case of TODBCConnection there is important: DatabaseName which converts to DSN= UserName which converts to USR= Password which converts to PWD= in connection string ... So chceck these settings. The ODBC connection has a Params property. Set the parameters in there, especially the database name. The property DatabaseName does not work for MS SQL connections (it's a bug). And as LacaK metioned use DSN= and not DatabaseName. Or on Window$ set up an ODBC connection via the config utility. ---------------------------------------------------------------------- Zath · 2016-05-16 22:21 I have set up the ODBC connection with the utility. That's an easy job. QuoteThe property DatabaseName does not work for MS SQL connections (it's a bug). And as LacaK metioned use DSN= and not DatabaseName. This explains some of the problems I was having then. Reading all the info, it says ODBC doesn't use DSN. ---------------------------------------------------------------------- LacaK · 2016-05-17 05:18 hm, if you set TODBCConnection.DatabaseName then it is used for DSN= in connection string. So it is used, but is used for Data Source Name as defined in ODBC driver manager. (if you do not define named connection in ODBC driver manager then of course DatabaseName is useless) if you want setup Database as per MS SQL Server https://msdn.microsoft.com/en-us/library/ms130822.aspx you must add to TODBCConnection.Params: 'Database=mydatabase' and probably: 'Server=myserver\myinstance'