AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi Problem bei Tadocommand

Problem bei Tadocommand

Ein Thema von R2009 · begonnen am 8. Mai 2009 · letzter Beitrag vom 8. Mai 2009
Antwort Antwort
R2009

Registriert seit: 9. Mär 2009
Ort: Heidelberg
440 Beiträge
 
Delphi 2007 Professional
 
#1

Problem bei Tadocommand

  Alt 8. Mai 2009, 07:45
Datenbank: Access • Zugriff über: TADOconnect
Hi,
warum funktioniert das nicht:
ich versuche eine bestehende Tabelle zu kopieren.
Fehlermeldung: Fehler in SQL Syntax

Delphi-Quellcode:
procedure create_table_by_copy(s:TADOcommand;name:string);
begin
  (s as TADOcommand).CommandText:='CREATE TABLE test SELECT * FROM Liste_D';
  (s as TADOcommand).Execute;
end;
Vielen Dank im Vorraus.
Rainer Unger
Mein Profil:
Studium Allgemeine Elektrotechnik TH Darmstadt
Entwicklung von Tools für die Rundsteuer und Zählertechnik.
uP's Atmel Prozessoren (ATmega16,32,88...) in C und Assembler.
  Mit Zitat antworten Zitat
JohannesK

Registriert seit: 17. Jul 2003
Ort: Abtwil
118 Beiträge
 
Delphi 2010 Professional
 
#2

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 07:56
Mit dem SQL-String versucht Du aus den Inhalten einer Tabelle eine neue Tabelle zu erzeugen. Geht natürlich nicht.
Die Felder einer Tabelle kannst Du auslesen mit SHOW FIELDS FROM xyz das CREATE Statement je nach verwendeter Datenbank mit SHOW CREATE TABLE xyz .

Du musst Dein Statement in zwei bis drei Schritte zerlegen: lesen der Definition, Änderung der Tabellenbezeichung mit stringreplace o.ä. und anlegen der neuen Tabelle.
mit freundlichem Gruss

So einfach wie möglich. Aber nicht einfacher.
  Mit Zitat antworten Zitat
R2009

Registriert seit: 9. Mär 2009
Ort: Heidelberg
440 Beiträge
 
Delphi 2007 Professional
 
#3

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 08:07
Hi Johannes,
danke für deine Antwrt. Versteh ich nicht.
Hab im Internet folgendes gefunden:

Zitat:
SQL COPY TABLE Command
For backup and other requirements we often have to copy the data of a table or copy the total table structure with data. We can selectively copy the data of a MySQL table to a new table or copy the total data to a new table. We will learn here different techniques on how to do this.

We can copy a table structure and records to another new table. The CREATE TABLE command will create a table with same structure of the old table and add all the records. To export data to an existing table you can use insert command.
CREATE TABLE student2 SELECT * FROM student
This will create a new table class2 using the structure of the table class and will copy all the records from table class to our new table class2.
Hab ich was falsch verstanden oder wo ist was falsch?

Vielen Dank!
Rainer Unger
Mein Profil:
Studium Allgemeine Elektrotechnik TH Darmstadt
Entwicklung von Tools für die Rundsteuer und Zählertechnik.
uP's Atmel Prozessoren (ATmega16,32,88...) in C und Assembler.
  Mit Zitat antworten Zitat
nahpets
(Gast)

n/a Beiträge
 
#4

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 08:18
Hallo,

das was in der Beschreibung für MySQL zum Create Table... steht, kann Access nicht.

Eventuell funktioniert ja
create table test as Select * from Liste_D Aber da geht probieren über studieren. Weiß nicht, ob das zum Standard gehört und welche Datenbank das dann zusätzlich auch noch unterstützt.
  Mit Zitat antworten Zitat
Benutzerbild von Ralf Kaiser
Ralf Kaiser

Registriert seit: 21. Mär 2005
Ort: Wuppertal
932 Beiträge
 
Delphi 10.3 Rio
 
#5

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 08:21
Zitat von R2009:
Zitat:
SQL COPY TABLE Command
For backup and other requirements we often have to copy the data of a table or copy the total table structure with data. We can selectively copy the data of a MySQL table to a new table or copy the total data to a new table. We will learn here different techniques on how to do this.
Hab ich was falsch verstanden oder wo ist was falsch?
In deinem ersten Beitrag hast du "Access" als Datenbank angegeben. Das was du da gefunden hast bezieht sich aber auf MySQL!!
Ralf Kaiser
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.169 Beiträge
 
Delphi 10.4 Sydney
 
#6

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 08:21
was pasiert wenn die Query direkt in Access ausgeführt wird?
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
JohannesK

Registriert seit: 17. Jul 2003
Ort: Abtwil
118 Beiträge
 
Delphi 2010 Professional
 
#7

Re: Problem bei Tadocommand

  Alt 8. Mai 2009, 08:52
Hab das mal schnell ausprobiert und bekomme auch nur eine Fehlermeldung bei ADO und Mydac-Kompos.
Im MySQL-Handbuch ist es so dokumentiert:
Zitat:
mysql> CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT,
-> PRIMARY KEY (a), KEY(b))
-> TYPE=MyISAM SELECT b,c FROM test2;

This creates a MyISAM table with three columns, a, b, and c. Notice that the columns from the SELECT statement are appended to the right side of the table, not overlapped onto it.
Möglicherweise nur im Konsolenmodus möglich, da funktioniert es. Vielleicht bleibt Dir doch nur das zerlegen.

völlig überlesen dass es sich um Access handelt, sorry
mit freundlichem Gruss

So einfach wie möglich. Aber nicht einfacher.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz