Re: [newbie] CDatabase problem



In addition to what Peter has recommended, and in response to your question
2:

Enclose TESTDB and TestTable in single quotes, since they are varchar
values:

db.ExecuteSQL("IF NOT EXISTS (SELECT [name] FROM sys.databases WHERE [name]
= 'TESTDB') CREATE DATABASE TESTDB");

db.ExecuteSQL("IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] =
'TestTable') CREATE TABLE TestTable(TIME DATETIME, MESSAGE CHARACTER
(200));");

"Peter Schmitz" <PeterSchmitz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9E9599FA-88E9-4356-9553-1C1C5193B9E9@xxxxxxxxxxxxxxxx
Hi,

I use CDatabase to connect to my SQL server databases, but I encounter the
following problems:

1. Although I provide the following connection string, the ODBC driver
always opens a window and asks the user to provide more information:

ODBC;DSN=SQLEXPRESS;UID=Peter;Trusted_Connection=Yes;APP=TODO: "Product
name";WSID=MYPC

I just can't figure out why...

2. The next step is to create a specific database on this server (if not
already existant) and to create a new table in this database (again, if
not
already existant). I use SQL statements for that:

db.ExecuteSQL("IF NOT EXISTS (SELECT [name] FROM sys.databases WHERE
[name]
= TESTDB) CREATE DATABASE TESTDB");

db.ExecuteSQL("IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] =
TestTable) CREATE TABLE TestTable(TIME DATETIME, MESSAGE CHARACTER
(200));");

Unfortunately, I receive a "TESTDB is an invalid column" error. Why?
Additionally, this code won't create the new table in the newly created
database - or would it? What is the correct code to do so?

3. I need to place some binary content in the databse - how can I do so?

Best wishes,

Peter


.



Relevant Pages

  • Re: [newbie] CDatabase problem
    ... Enclose TESTDB and TestTable in single quotes, ... The next step is to create a specific database on this server (if not ... already existant). ... What is the correct code to do so? ...
    (microsoft.public.vc.mfc)
  • Re: Full Text Search Performance
    ... system that is 50 times slower for the simplest query that does not have much ... The drive letter that is used by the database is E, ... I have read something about configuring SQL to use a fixed memory on ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Restore database
    ... Tibor Karaszi, SQL Server MVP ... I did a backup for application database: testdb ...
    (microsoft.public.sqlserver.setup)
  • Re: Restore database
    ... No need to create a database before you restore it. ... I did a backup for application database: testdb ...
    (microsoft.public.sqlserver.setup)
  • Re: [newbie] CDatabase problem
    ... I use CDatabase to connect to my SQL server databases, ... The next step is to create a specific database on this server (if not ... I receive a "TESTDB is an invalid column" error. ... What is the correct code to do so? ...
    (microsoft.public.vc.mfc)