Re: [newbie] CDatabase problem



"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...


You can use CDatabase::OpenEx() with the CDatabase::noOdbcDialog option.



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?


See http://msdn2.microsoft.com/en-us/library/s55kt8s3(vs.80).aspx



Best wishes,

Peter



--
Mark Salsbery
Microsoft MVP - Visual C++



.



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: [newbie] CDatabase problem
    ... In addition to what Peter has recommended, and in response to your question ... Enclose TESTDB and TestTable in single quotes, ... The next step is to create a specific database on this server (if not ... What is the correct code to do so? ...
    (microsoft.public.vc.mfc)
  • Re: DTS Changing data type from numeric to decimal
    ... selected Copy objects and data between sql server databases. ... the tables on the destination, I assume it must have done hence the problem. ... >> If you used DTS to generate some tables then it is possible. ... > to transfer the database to a cluster that is case insenseitive. ...
    (microsoft.public.sqlserver.dts)
  • SQL server integration with Outlook VBA
    ... I have been trying to integrate Outlook with an SQL database, ... though I am a newbie to SQL server databases. ... Dim Dbcon As New ADODB.Connection ...
    (microsoft.public.outlook.program_vba)
  • [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)