Re: [newbie] CDatabase problem
- From: "Ashot Geodakov" <a_geodakov@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 1 Oct 2007 15:28:11 -0700
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
.
- Follow-Ups:
- Re: [newbie] CDatabase problem
- From: Ashot Geodakov
- Re: [newbie] CDatabase problem
- Prev by Date: Re: PreCreateWindow() & CListBox
- Next by Date: Re: [newbie] CDatabase problem
- Previous by thread: Re: [newbie] CDatabase problem
- Next by thread: Re: [newbie] CDatabase problem
- Index(es):
Relevant Pages
|