Again..HOWTO Create TTable on the fly....
Hello all,
I know I have seen this addressed before, but, I have lost all references to it
(I should know better that to clean my office). I am trying to create and
manipulate tables hooking to an MS SQL server programiatically. Basically I am
using some code I inherited to read from a file that used to be hooked to a
form which had TTable components hooked to local tables. I have gotten rid of
the forms and am re-directing the files to a table I have on a MS SQL
server6.0. How do I go about doing a create table? Where do I declare it in
the unit? Here is what I am starting with that does not work. Also, do I have
to declare all of the fields that will be going into the TTAble, and if so
where? Here is what I am starting with:
var
tblMERs: TTable;
tblMERsNumber: TSmallintField;
tblMERsName: TStringField;
tblMERsType: TSmallintField;
tblMERsGroupNumber: TSmallintField;
tblMERsElementGroups: TStringField;
tblMERsHeading: TStringField;
............etc
const
strNetworkMERDataFile = 'o:\inf\mer\';
strLaptopMERDataFile = 'c:\ales\mer\';
......etc
procedure DoIt ;
begin
if FileExists(strNetworkMERDataFile + 'database.dat') then
begin
strMERDirectory := strNetworkMERDataFile;
getDatabaseNames(strNetworkMERDataFile + 'database.dat')
end
else
begin
strMERDirectory := strLaptopMERDataFile;
getDatabaseNames(strLaptopMERDataFile + 'database.dat');
end;
with tblMERs do
begin
Active := False;
DatabaseName := 'InfoBaseSQL';
TableName := 'dbo.MasterElement';
CreateTable;
end;
Here in the last part in the code is where I am trying to create the table
tblMERs. When it hits this part, I get the Access Violation.
Any help to get me pointed in the right direction will be greatly appreciated.
Everything I have done so far has involved using forms and dropping the
components in.
Thanx!!!
Kelly
kgr...@acxiom.com