ADO - create table and fields in code (Access)

I am able to create a table using the following code but I need to create a 
memo field in Microsoft Access. Anyone know how to create a memo field is 
greatly appreciated.

Thanks in advance.

Andy


var
 Cat,Table,Col,Key: Variant;

        Cat := CreateOLEObject('ADOX.Catalog');
        Cat.ActiveConnection := ADODatabase1.DatabaseConnect;

        Table := CreateOLEObject('ADOX.Table');

        Table.Name := 'TEMPTABLE';

        //integer - primary - autoincrement
        sKey := 'TEMPPROFILEID';
        Col := CreateOLEObject('ADOX.Column');
        Col.ParentCatalog := Cat;
        Col.Name := sKey;
        Col.Type := adInteger;
        Col.Properties('Autoincrement') := True;
        Table.Columns.Append(Col);

        Key := CreateOLEObject('ADOX.Key');
        Key.Name := 'Primary';
        Key.Type := adKeyPrimary;
        Key.Columns.Append(sKey);
        Table.Keys.Append(Key);

        //integer
        sKey := 'SID';
        Col := CreateOLEObject('ADOX.Column');
        Col.ParentCatalog := Cat;
        Col.Name := sKey;
        Col.Type := adInteger;
        Table.Columns.Append(Col);

        //string
        sKey := 'SID_NAME';
        Col := CreateOLEObject('ADOX.Column');
        Col.ParentCatalog := Cat;
        Col.Name := sKey;
        Col.Attributes := adColNullable;
        Col.DefinedSize := 100;
        Col.Type := adVarWChar;
        Table.Columns.Append(Col);


        Cat.Tables.Append(Table);

        Key := null;
        Col := null;
        Table := null;

        Cat := null;
1
Andy
1/14/2009 5:47:45 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

5 Replies
1513 Views

Similar Articles

[PageSpeed] 8

> {quote:title=Andy Colmes wrote:}{quote}
> I am able to create a table using the following code but I need to create a 
> memo field in Microsoft Access. Anyone know how to create a memo field is 
> greatly appreciated.

I'm not using ADO that way, but it seems to me you could create a table with a memo field in Access and then open it using ADO and see what type it wanted for the memo field. Wouldn't that work? (Sorry if for some reason it won't; the thought just came to me as I read your post.)

Also, you might get a quicker (and more knowledgeable) response by posting in the Database.ADO forums. :-)
0
Ken
1/14/2009 8:16:03 PM
Hi Ken,

I've tried to set the type to advarLongWChar or something like that as 
defined in ADO constants, but it does not like it. I'll try posting in the 
ADO forums. Thanks.

Andy

"Ken White" wrote in message news:67383@forums.codegear.com...
>> {quote:title=Andy Colmes wrote:}{quote}
>> I am able to create a table using the following code but I need to create 
>> a
>> memo field in Microsoft Access. Anyone know how to create a memo field is
>> greatly appreciated.
>
> I'm not using ADO that way, but it seems to me you could create a table 
> with a memo field in Access and then open it using ADO and see what type 
> it wanted for the memo field. Wouldn't that work? (Sorry if for some 
> reason it won't; the thought just came to me as I read your post.)
>
> Also, you might get a quicker (and more knowledgeable) response by posting 
> in the Database.ADO forums. :-)
0
Andy
1/14/2009 8:36:38 PM
Andy Colmes wrote:
> I am able to create a table using the following code but I need to create a 
> memo field in Microsoft Access. Anyone know how to create a memo field is 
> greatly appreciated.
> 
> Thanks in advance.
> 
> Andy
> 
> 
> var
>  Cat,Table,Col,Key: Variant;
> 
>         Cat := CreateOLEObject('ADOX.Catalog');
>         Cat.ActiveConnection := ADODatabase1.DatabaseConnect;
> 
>         Table := CreateOLEObject('ADOX.Table');
> 
>         Table.Name := 'TEMPTABLE';
> 
>         //integer - primary - autoincrement
>         sKey := 'TEMPPROFILEID';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Type := adInteger;
>         Col.Properties('Autoincrement') := True;
>         Table.Columns.Append(Col);
> 
>         Key := CreateOLEObject('ADOX.Key');
>         Key.Name := 'Primary';
>         Key.Type := adKeyPrimary;
>         Key.Columns.Append(sKey);
>         Table.Keys.Append(Key);
> 
>         //integer
>         sKey := 'SID';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Type := adInteger;
>         Table.Columns.Append(Col);
> 
>         //string
>         sKey := 'SID_NAME';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Attributes := adColNullable;
>         Col.DefinedSize := 100;
>         Col.Type := adVarWChar;
>         Table.Columns.Append(Col);
> 
> 
>         Cat.Tables.Append(Table);
> 
>         Key := null;
>         Col := null;
>         Table := null;
> 
>         Cat := null;
Andy -
Check out:
http://allenbrowne.com/func-ADOX.html#CreateTableAdox
Mike
0
Mike
1/15/2009 2:20:48 PM
> {quote:title=Andy Colmes wrote:}{quote}
> I am able to create a table using the following code but I need to create a 
> memo field in Microsoft Access. Anyone know how to create a memo field is 
> greatly appreciated.
> 
> Thanks in advance.
> 
> Andy
> 
> 
> var
>  Cat,Table,Col,Key: Variant;
> 
>         Cat := CreateOLEObject('ADOX.Catalog');
>         Cat.ActiveConnection := ADODatabase1.DatabaseConnect;
> 
>         Table := CreateOLEObject('ADOX.Table');
> 
>         Table.Name := 'TEMPTABLE';
> 
>         //integer - primary - autoincrement
>         sKey := 'TEMPPROFILEID';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Type := adInteger;
>         Col.Properties('Autoincrement') := True;
>         Table.Columns.Append(Col);
> 
>         Key := CreateOLEObject('ADOX.Key');
>         Key.Name := 'Primary';
>         Key.Type := adKeyPrimary;
>         Key.Columns.Append(sKey);
>         Table.Keys.Append(Key);
> 
>         //integer
>         sKey := 'SID';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Type := adInteger;
>         Table.Columns.Append(Col);
> 
>         //string
>         sKey := 'SID_NAME';
>         Col := CreateOLEObject('ADOX.Column');
>         Col.ParentCatalog := Cat;
>         Col.Name := sKey;
>         Col.Attributes := adColNullable;
>         Col.DefinedSize := 100;
>         Col.Type := adVarWChar;
>         Table.Columns.Append(Col);
> 
> 
>         Cat.Tables.Append(Table);
> 
>         Key := null;
>         Col := null;
>         Table := null;
> 
>         Cat := null;


I think it might not be the best approach you can execute a SQL statement with a ADO command of type
create <table name> (
<fieldname1 MEMO>
)
that works always
I have some code written somewhere to automate that 
contact me if you wish philippe@triaina.com
PW
0
Philippe
1/16/2009 9:28:12 AM
Hi Philippe,

Thanks very much for the recommendation. I will try to create the table with 
SQL instead. Might be easier too.

Andy

"Philippe Watel" wrote in message news:68295@forums.codegear.com...
>> {quote:title=Andy Colmes wrote:}{quote}
>> I am able to create a table using the following code but I need to create 
>> a
>> memo field in Microsoft Access. Anyone know how to create a memo field is
>> greatly appreciated.
>>
>> Thanks in advance.
>>
>> Andy
>>
>>
>> var
>>  Cat,Table,Col,Key: Variant;
>>
>>         Cat := CreateOLEObject('ADOX.Catalog');
>>         Cat.ActiveConnection := ADODatabase1.DatabaseConnect;
>>
>>         Table := CreateOLEObject('ADOX.Table');
>>
>>         Table.Name := 'TEMPTABLE';
>>
>>         //integer - primary - autoincrement
>>         sKey := 'TEMPPROFILEID';
>>         Col := CreateOLEObject('ADOX.Column');
>>         Col.ParentCatalog := Cat;
>>         Col.Name := sKey;
>>         Col.Type := adInteger;
>>         Col.Properties('Autoincrement') := True;
>>         Table.Columns.Append(Col);
>>
>>         Key := CreateOLEObject('ADOX.Key');
>>         Key.Name := 'Primary';
>>         Key.Type := adKeyPrimary;
>>         Key.Columns.Append(sKey);
>>         Table.Keys.Append(Key);
>>
>>         //integer
>>         sKey := 'SID';
>>         Col := CreateOLEObject('ADOX.Column');
>>         Col.ParentCatalog := Cat;
>>         Col.Name := sKey;
>>         Col.Type := adInteger;
>>         Table.Columns.Append(Col);
>>
>>         //string
>>         sKey := 'SID_NAME';
>>         Col := CreateOLEObject('ADOX.Column');
>>         Col.ParentCatalog := Cat;
>>         Col.Name := sKey;
>>         Col.Attributes := adColNullable;
>>         Col.DefinedSize := 100;
>>         Col.Type := adVarWChar;
>>         Table.Columns.Append(Col);
>>
>>
>>         Cat.Tables.Append(Table);
>>
>>         Key := null;
>>         Col := null;
>>         Table := null;
>>
>>         Cat := null;
>
>
> I think it might not be the best approach you can execute a SQL statement 
> with a ADO command of type
> create <table name> (
> <fieldname1 MEMO>
> )
> that works always
> I have some code written somewhere to automate that
> contact me if you wish philippe@triaina.com
> PW
0
Andy
1/16/2009 2:18:31 PM
Reply:

Similar Artilces:

Crystal 11 and Delphi 7
Hello. I use CR11 and the VCL in D7. In the code, I have a front end query processor. The Crystal vcl has a property named filterstring and that is how I do record selection. What I want to do is be able to print one of the selection parameters in the report. If I drop a text object in the header in the Crystal designer, is there a way to burrow into the report fields from the Delphi code to force content into the field? For example, say I have a transaction report. I select transactions with a start/end date in the Delphi app. Within the Crystal report itself, I want to somehow forc...

How to call or retrieve fields from sql and display in table without using ADO.net, I'm using a dynamic link library....Is the coding different?
Help me! I'm doing my school project on Software Change Management Tool, CR Tracker. I want to display table in the webform, and the table data is retrieve form the sql server. So how do I call the sql so as to display the data in a table? hy..What does that dll contain ?Does it already contains relevant code to connect to a database ? Have a look hereThanksDinuj Nath The easy way to do this is with the use of a data bound grid. The Grid can be customised to look and feel you like. You will need to add a data adapter to your page and a grid. When you setup the data adapter you will nee...

Can ADO.Net query/update a MS Access database that contains table and fields that contain blank spaces and characters such as "#" in their names?????
I've recently been assigned an asp.net/MS Access project. My code works fine; however, there are table and fields in the Access database that contain blank spaces and characters such as "#" in their names. For example there is a table named "Purchase Orders" and in this table there are a few column fields with names such as "PO#" and “Customer PO#". My question: Is there some sort of wrapping method that I need to implement to allow my ADO.net objects (particularly the "OleDbDataAdapter" and the "DataRow") to accept these naming...

Access to code table
If I have a column on a datawindow of type DDLB, can I get access to the code table of that edit style? For example if I define a DDLB with the following code table: Display Value Data Value Choice1 C1 Choice2 C2 how can I get to these values at run time? Thanks, Juan Try to use GetValue function. Thanks, Anand Kumar Juan Garcia <jua@inel.gov> wrote in message news:38FE1290.E2EF1C9F@inel.gov... > If I have a column on a datawindow of type DDLB, can I get access to the > code table of that edit style? For example if I defin...

Code table access
Hi; I am using code table in a grid datawindow. The problem is how I can get the edited value from the column. Example: Two lines in code table: display data 20.1 50.2 23.6 52.3 The grid has two lines width displayvalue 20.1 and 23.6. If I edit line 1 and change the value to 23.6 (same as line 2 in code table) I am not able to get the edited value from line 1 in the itemchanged event of the datawindow. Gettex() and data argument gives me both value 52.3 (the ...

accessing a field from a table?
id limit engine_size ncb tpo tpft comp 0 2000 1800 1 337 369 386 1 2000 1800 2 263 281 300 2 2000 1800 3 225 241 258 3 2000 1800 4 207 223 242 4 2000 1800 5 190 195 215 5 2000 2200 1 391 420 448 6 2000 2200 2 304 327 348 7 2000 2200 3 261 280 299 8 2000 2200 4 240 256 274 9 2000 2200 5 209 223 226 10 2000 3500 1 505 541 577 11 2000 3500 2 392 420 449 12 2000 3500 3 337 361 385 13 2000 3500 4 309 330 352 14 2000 3500 5 270 288 308 15 2000 35...

accessing a table fields
Dear all, I have a seperate table and i want to show the fields of another table in this new table. Is there any hint to do it. thanks ...

Access to fields in a table
I am trying to access the fields in a table using Visual Basic in Web Developer .NET Start with the link below and click on SelectCommand, InsertCommand, DeleteCommand and UpdateCommand to get tbe basic of manipulating data in the database through ADO.NET.  Hope this helps. http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspxKind regards,Gift Peddie...

Dynamic table generation by JavaScript, Accessing row and data of dynamic table in C# code
  <div>   <input id="txtName" type="text"/> <input id="txtAdd" type="text"/> <input id="txtCity" type="text"/>   <input id="btnAdd" type="button" value="Add" onclick="AddClick();" /> <input id="btnRemove" type="button" value="Remove" onclick="RemoveClick(this);"/><br /> <table id="tblInfo" runat="server" style="width: 474px" > </table> </div&g...

Is having a trigger that inserts a row in Table 'A', when a row in same table is inserted by ADo.Net code?
I want to insert a row for a Global user  in Table 'A' whenever ADO.Net code inserts a Local user row into same table. I recommended using a trigger to implement this functionality, but the DBA was against it, saying that stored proecedures should be used, since triggers are unreliable and slow down the system by placing unecessary locks on the table. Is this true OR the DBA is saying something wrong? My thinking is that Microsoft will never include triggers if they are unreliable and the DBA is just wanting to offload the extra DBA task of triggers to the programmer so that a s...

Do the fields in a Table Adapter have to exactly match the fields of the Data Table?
When I add a new Table Adapter to a Data Table I get the following error: The new command text returns data with schema different from the schema of the main query....  I'm using less fields than the Table Adapter used so I'm guessing that is bad and I should just create a new Data Table for my needs. Is that true?   Thanks.  ...

How to Access SqlDataSource Fields from Code?
I have <asp:SqlDataSource> in aspx page that is being used by an updateable GridView.  However, there are a couple fields in the dataset that contain filenames that I want to access directly in code and place them into some image tags on the page. This line should give me access to the dataset but how to I access the fields? Dim myDataSource As DataView = DirectCast(SqlDataSourceGridView.[Select](DataSourceSelectArguments.Empty), DataView) When the SqlDataSource is a DataReader I would access it with the code below but since this SqlDataSource is a DataS...

Adding field to Access table?
This may sound like a dumb question and I apologize ahead of time. I found the access database 'DotNetNuke.mdb.resources' which is where the data is being stored. I added a field to one of the tables, specifically the 'DotNetNuke_Banners' table. Basically, I've added a description field that I want to appear with the banner ads. I've also updated all the queries in the database which reference this table. Now, the dumb question: I cannot find where to add this field in the site? In the old IBuy Spy portal you had the xxxDB.vb files in the components directory where you would updat...

Direct access to the fields in a table
I want to access the fields in a table directly.  How can this be done? Is the table asp:Table or html table?  Post relevant code. The tables would be in ASP. I was hoping for a simple example to get me going.  I have never done it before and the training sites have so much information before getting to the point. If you can help me I would appreciate it. Can you please explain about your scenario?  What kind of table and controls you want, is the values will be data driven, and when and what kind of information do you want to retrieve?  If you give that, the...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Web resources about - ADO - create table and fields in code (Access) - embarcadero.delphi.general

Wikipedia:Why create an account? - Wikipedia, the free encyclopedia
This is Wikipedia . You do not have to log in to learn. Almost anyone can edit almost any article at any given time too, but be aware that the ...

Facebook Teams Up With Google, Microsoft, Others To Create WebPlatform.org, A Developer Support Hub
Facebook may have a tricky relationship with HTML5 , but it still wants developers all over the Web to learn how to use it efficiently. The social ...

Another Lawmaker Is Trying To Create A Photography-Free Zone For Police Officers
"Say cheese!" is not a phrase that bacon wants to hear.

Create your own mashup videos with ease, just use KnowMe
... 8 or later, and is designed for iPhone, iPad, and iPod touch. Its a free download on the App Store, without any ads or in-app purchases. Create ...

Create the Perfect Email Signature With This Cheat Sheet
... – yet. How does your email signature look? Here is a great infographic that will guide you in creating the perfect email signature. Create ...

"Saudi Arabia’s top cleric has declared the playing of chess 'forbidden'... a waste of time and money ...
Grand Mufti Sheikh Abdulaziz Al-Sheikh called it “the work of Satan.” “It makes the rich man poor, and makes the poor man rich,” he said. “It ...

U.S. military wants to create cyborg soldiers
The U.S. military is working to create a chip that can be implanted in a soldier's brain to connect it directly to computers that can deliver ...

QuickBooks Recruits App Developers To Create Greater End-User Value
... thought leadership are all solid business drivers. But how can a company employ such theories in practical, timely and effective ways to create ...

Google creates fix for zero-day kernel flaw, says effect on Android is greatly exaggerated
Google has developed a patch for a recently reported vulnerability in the Linux kernel and shared it with Android manufacturers.

Scientists create innovative hydrogen fuel “nano-reactor” that could make hydrogen cars much cheaper
Hydrogen fuel cells may have just taken a giant leap forward. Indiana University scientists just announced they’ve managed to create a highly ...

Resources last updated: 1/22/2016 9:05:43 PM