Board index » delphi » Please Help (This message Pertains to SQL and the Create Table SQL Statement)

Please Help (This message Pertains to SQL and the Create Table SQL Statement)

Hello, and how is everyone doing?

   This is my problem.  I am trying to create a table using SQL statements
and would like to know the following:

I drop a TQuery component, a TDataSource component and a TDBGrid component
on my form and link them all together.  I then type in the TQuery's SQL
property the following:

Create Table Test(
    Name          Char(40),
    Telephone    Char(13),
    Address       Char(25),
Primary Key(Name)
)

To my knowlege, this should create a table called Test with the following
Fields:

Name
Telephone
Address

When I set the TQuery's Active property to True, it states the error
Message:

Error Creating Cursor Handle

What does this mean? and why won't it show the fields (Name, Telephone and
Address) of the Test Table in my TDBGrid that I've positioned on my form
and linked in with the DataSource Component?

I've taken a look in my directory and the table exists called Test.db and
when I start a new project and use a TTable Component instead of a TQuery
component and link it to the tablename test.db and to the datasource
dbdemos then set the active property to true, it shows the 3 fields: Name,
Telephone and Address in my DBGrid Component with no problem.

What am I doing wrong?  How do I get it to appear using the TQuery
component instead of getting that error when I set the active property?

Any help would be greatly appreciated!!

P.S.  If you do not mind sending a copy to my e-mail address (listed below)
as well, that would be greatly appreciated for I do not get to read the
newsgroups that frequently, but do recieve my e-mail on an hourly basis.

Thanks for your Time, Help and Co-Operation!!

Shane Escher
e-mail: starg...@smartt.com

 

Re:Please Help (This message Pertains to SQL and the Create Table SQL Statement)


You should call the query's execsql method, not open (or active).  Queries
that return data should be done with open (active).  Those that don't need
to call execsql instead.

-Dave

In article <01bc6226$85a825c0$141e66cf@hacker>, starg...@smartt.com
says...

Quote

>Hello, and how is everyone doing?

>   This is my problem.  I am trying to create a table using SQL
statements
>and would like to know the following:

>I drop a TQuery component, a TDataSource component and a TDBGrid
component
>on my form and link them all together.  I then type in the TQuery's SQL
>property the following:

>Create Table Test(
>    Name          Char(40),
>    Telephone    Char(13),
>    Address       Char(25),
>Primary Key(Name)
>)

>To my knowlege, this should create a table called Test with the following
>Fields:

>Name
>Telephone
>Address

>When I set the TQuery's Active property to True, it states the error
>Message:

>Error Creating Cursor Handle

>What does this mean? and why won't it show the fields (Name, Telephone
and
>Address) of the Test Table in my TDBGrid that I've positioned on my form
>and linked in with the DataSource Component?

>I've taken a look in my directory and the table exists called Test.db and
>when I start a new project and use a TTable Component instead of a TQuery
>component and link it to the tablename test.db and to the datasource
>dbdemos then set the active property to true, it shows the 3 fields:
Name,
>Telephone and Address in my DBGrid Component with no problem.

>What am I doing wrong?  How do I get it to appear using the TQuery
>component instead of getting that error when I set the active property?

>Any help would be greatly appreciated!!

>P.S.  If you do not mind sending a copy to my e-mail address (listed
below)
>as well, that would be greatly appreciated for I do not get to read the
>newsgroups that frequently, but do recieve my e-mail on an hourly basis.

>Thanks for your Time, Help and Co-Operation!!

>Shane Escher
>e-mail: starg...@smartt.com

--
-------------------------------------------------------
Pacifier Online Data Service Dialup SLIP/PPP User
To register: (360) 693-0325 or telnet pods.pacifier.com
-------------------------------------------------------

Re:Please Help (This message Pertains to SQL and the Create Table SQL Statement)


Quote
"Shane Escher" <starg...@smartt.com> writes:
>Hello, and how is everyone doing?

Well I'm OK, but I can't answer for *everyone*. <h>

Quote
>   This is my problem.  I am trying to create a table using SQL statements
>and would like to know the following:
>I drop a TQuery component, a TDataSource component and a TDBGrid component
>on my form and link them all together.  I then type in the TQuery's SQL
>property the following:
>Create Table Test(
>    Name          Char(40),
>    Telephone    Char(13),
>    Address       Char(25),
>Primary Key(Name)
>)
>To my knowlege, this should create a table called Test with the following
>Fields:
>Name
>Telephone
>Address
>When I set the TQuery's Active property to True, it states the error
>Message:
>Error Creating Cursor Handle
>What does this mean? and why won't it show the fields (Name, Telephone and
>Address) of the Test Table in my TDBGrid that I've positioned on my form
>and linked in with the DataSource Component?

Because it's not a SELECT. If you want to create a table, you need to use
ExecSQL. Setting Active to true is the same as calling Open, which will
expect a result set, as returned by a SELECT.
[snip]

Quote
>P.S.  If you do not mind sending a copy to my e-mail address (listed below)
>as well, that would be greatly appreciated for I do not get to read the
>newsgroups that frequently, but do recieve my e-mail on an hourly basis.

Whups! Sorry, but my newsreader does one or the other, not both.

--
Luke Webber

* Note: The opinions expressed by Luke Webber are in no way supported *
*       by his employers, Luke Webber Consulting Services             *

Other Threads