{"id":18771,"date":"2022-11-01T22:33:40","date_gmt":"2022-11-01T17:03:40","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/"},"modified":"2022-11-01T22:33:40","modified_gmt":"2022-11-01T17:03:40","slug":"solved-display-database-structure-from-delphi-rad-studio","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/","title":{"rendered":"[Solved] Display database structure from Delphi (rad studio)"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-43139863\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"43139863\" data-parentid=\"43135621\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>As already explained to you in comments, your <code>while<\/code> loop should look something like this:<\/p>\n<pre><code> while **not** FData.FDQuery1.Eof do **begin**\n    ShowMessage(FData.FDQuery1.Fields[0].ToString);\n    **FData.FDQuery1.Next;**\n end;\n<\/code><\/pre>\n<p>(minus the asterisks, of course).  However, that would not overcome the problem that your SQL is incorrect.<\/p>\n<p>So, try this instead:<\/p>\n<ol>\n<li>\n<p>In a new Delphi project, place a TFDConnection, TFDQuery, TDataSource,<br \/>\nTDataSource and a TListBox on a form.  Save the form and project.<\/p>\n<\/li>\n<li>\n<p>Double-click FDConnection1 to pop up its connection editor and configure<br \/>\nit so you can successfully connect it to your database.<\/p>\n<\/li>\n<li>\n<p>Connect DBGrid1 to DataSource1 and Datasource1 to FDQuery1.<\/p>\n<\/li>\n<li>\n<p>Add the code below to the form&#8217;s OnCreate event.<\/p>\n<\/li>\n<li>\n<p>Compile and run.<\/p>\n<\/li>\n<li>\n<p>You should immediately see the cause of your problem.  As the error message<br \/>\ntold you, there is no strDBName field in the INFORMATION_SCHEMA.TABLES table.<\/p>\n<\/li>\n<\/ol>\n<p>So you need to backtrack to the MySQL online help, starting e.g. here<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/tables-table.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/tables-table.html<\/a><\/p>\n<p>and work out exactly what it is that you are looking for,<br \/>\nif you don&#8217;t already know, and how to get it from within your project.<\/p>\n<p>Btw, if you are not sure what you are doing, you should always try your SQL first in the MySql Workbench utility.<\/p>\n<p>Code<\/p>\n<pre><code>  FDQuery1.SQL.Text := 'SELECT * FROM INFORMATION_SCHEMA.TABLES';\n  FDQuery1.Open;\n  FDQuery1.GetFieldNames(ListBox1.Items);\n<\/code><\/pre>\n<p>I have a MySql database called &#8216;MATestDB&#8217;.  To get a list of the fields (columns) in its tables, I would add this code to TForm1.FormCreate:<\/p>\n<pre><code>  FDQuery2.SQL.Text := 'select * from information_schema.columns where table_schema=\"\"MATestDB''';\n  FDQuery2.Open;\n<\/code><\/pre>\n<p>If you want FDQuery2 and its grid to track the selected table in FDQuery1, you can use code like the following to set up a <code>master-detail<\/code> relationship between them:<\/p>\n<pre><code>procedure TForm1.FormCreate(Sender: TObject);\nbegin\n  FDQuery1.SQL.Text := 'SELECT * FROM INFORMATION_SCHEMA.TABLES';\n\n  FDQuery2.SQL.Text := 'select table_schema, table_name, column_name, data_type, character_maximum_length, ordinal_position from information_schema.columns where table_schema = :Table_Schema and table_name = :Table_Name';\n  FDQuery2.IndexFieldNames := 'table_schema;table_name;ordinal_position';\n  FDQuery2.MasterFields := 'table_schema;table_name';\n  FDQuery2.MasterSource := DataSource1;\n\n  FDQuery1.Open;\n  FDQuery1.GetFieldNames(ListBox1.Items);\n\n  FDQuery2.Open;\n  FDQuery2.GetFieldNames(ListBox2.Items);\n\nend;\n<\/code><\/pre>\n<p>Btw, you will not be able to get schema info for a Paradox database in the same way, but you should be able to google how to find out what information you want to gather from Paradox.<\/p>\n<p>Btw #2: In the Sql you quoted in your deleted answer, one problem would be the reference to <code>DBGrid2.SelectedField.ToString<\/code>.  If DBGrid2 gets its data from FDQuery2, then you may have meant <code>DBGrid**1**.SelectedField.ToString<\/code>.  If you are still having problem with that, I suggest you ask about it in a new q, but make sure you include all the code necessary to reproduce the problem.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Display database structure from Delphi (rad studio) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] As already explained to you in comments, your while loop should look something like this: while **not** FData.FDQuery1.Eof do **begin** ShowMessage(FData.FDQuery1.Fields[0].ToString); **FData.FDQuery1.Next;** end; (minus the asterisks, of course). However, that would not overcome the problem that your SQL is incorrect. So, try this instead: In a new Delphi project, place a TFDConnection, TFDQuery, TDataSource, &#8230; <a title=\"[Solved] Display database structure from Delphi (rad studio)\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\" aria-label=\"More on [Solved] Display database structure from Delphi (rad studio)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[740,340,4522,4521],"class_list":["post-18771","post","type-post","status-publish","format-standard","hentry","category-solved","tag-delphi","tag-mysql","tag-paradox","tag-rad"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Display database structure from Delphi (rad studio) - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Display database structure from Delphi (rad studio) - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] As already explained to you in comments, your while loop should look something like this: while **not** FData.FDQuery1.Eof do **begin** ShowMessage(FData.FDQuery1.Fields[0].ToString); **FData.FDQuery1.Next;** end; (minus the asterisks, of course). However, that would not overcome the problem that your SQL is incorrect. So, try this instead: In a new Delphi project, place a TFDConnection, TFDQuery, TDataSource, ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-01T17:03:40+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Display database structure from Delphi (rad studio)\",\"datePublished\":\"2022-11-01T17:03:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\"},\"wordCount\":366,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"delphi\",\"mysql\",\"paradox\",\"rad\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\",\"name\":\"[Solved] Display database structure from Delphi (rad studio) - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-11-01T17:03:40+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Display database structure from Delphi (rad studio)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Display database structure from Delphi (rad studio) - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Display database structure from Delphi (rad studio) - JassWeb","og_description":"[ad_1] As already explained to you in comments, your while loop should look something like this: while **not** FData.FDQuery1.Eof do **begin** ShowMessage(FData.FDQuery1.Fields[0].ToString); **FData.FDQuery1.Next;** end; (minus the asterisks, of course). However, that would not overcome the problem that your SQL is incorrect. So, try this instead: In a new Delphi project, place a TFDConnection, TFDQuery, TDataSource, ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/","og_site_name":"JassWeb","article_published_time":"2022-11-01T17:03:40+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Display database structure from Delphi (rad studio)","datePublished":"2022-11-01T17:03:40+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/"},"wordCount":366,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["delphi","mysql","paradox","rad"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/","url":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/","name":"[Solved] Display database structure from Delphi (rad studio) - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-11-01T17:03:40+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-display-database-structure-from-delphi-rad-studio\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Display database structure from Delphi (rad studio)"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/18771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=18771"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/18771\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=18771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=18771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=18771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}