Re: How to access the SQL server express from mfc application?



Hello,
There are different ways to do this via MFC. You could certainly try ADO,
OLEDB, etc, and other technologies. As a matter of fact, the project I am
working on actively involves me writing an MFC app that communicates with a
local SQL Server Express database on the client side, and then later sending
the entire contents of the database to a SQL Server Standard Server. In
general, I have found ADO to be a good companion for working with SQL Server
Express. I suppose to clarify, ADO is basically one of the main frameworks
that you use in MFC to talk to a database (it could be SQL Server Express,
SQL Server Enterprise, Excel, Oracle, mySQL, etc.)
You want to watch out for a couple of things Kueishiong:

1) How are you communicating with the database? Is it a local connection
(and hence encryption may not be as necessarry) or via a network connection
(where encryption and other security measures built into the software will be
needed!)
2) Read up about T-SQL. While this may seem like an obvious thing to say,
you will likely need to know T-SQL very well since you might need it if say
your application wants to rebuild the database from scratch.
3) You want to know about some of the key areas of SQL in general, such as
stored procedures and functions (aka the progammability component of any
database within the SQL Server engine). Did you know that it doesn't make
sense for the most part to issue queries via ADO, even though you can? If
your most common queries are stored procedures in a database they will run
several times faster since stored procedures in SQL Server than a query that
you send through ADO. This is because stored procedures in SQL Server are
precompiled once they are created, and hence everytime you call a stored
procedure, and provide the requisite parameters, it will execute very quickly
because it is the database engine that merely executes a valid query with a
set number of valid parameters. This also has the wonderful advantage of
increasing the security of the MFC to SQL Server interface since executing
stored procedures is safer than executing a dynamic query from ADO.

Anyway, I hope that gives you a little glance of ADO for MFC. Certainly the
first time you talk to SQL Server via MFC you may notice that it takes a
couple of seconds for your first query/stored procedure to run, and that can
all be tuned out later. Regarding MFC support, while it is true that there
is support in Visual Studio .NET 2003, for MFC, Microsoft has decided that
all express editions of Visual Studio (including 2008), will not have
"native," nor MFC support. In other words to get MFC in Visual Studio you
need standard edition or better. The following is a useful article I used in
helping me use ADO:

Overview of ADO:
http://www.codeproject.com/KB/database/simpleado.aspx
Discussion on connection strings - vital for understanding how ADO connects
to other datasources:
http://www.codeproject.com/KB/database/connectionstrings.aspx

Hope the resources help.

Regards,

James Simpson
Straightway Technologies Inc.
.



Relevant Pages

  • Re: Access and processor usage
    ... "increased bandwidth" using ADO. ... bottleneck - need to step up to Sql Server. ... If the data fits into a 2 GB database file, ...
    (comp.databases.ms-access)
  • Re: How to access the SQL server express from mfc application?
    ... There are different ways to do this via MFC. ... You could certainly try ADO, ... the entire contents of the database to a SQL Server Standard Server. ...
    (microsoft.public.vc.mfc)
  • Re: Connecting to a SQL Server 2005 using VBA and ADO
    ... dao should work just fine.... ... the above example when using sql server, or a plan Jane un-split database, ... I would not use findfirst even when not using sql server unless the data set ... Microsoft since they now seem to be favoring ADO. ...
    (microsoft.public.access.formscoding)
  • Re: Access and processor usage
    ... developers to get together and develop reproducible test scenarios, ... See http://www.QBuilt.com for all your database needs. ... "increased bandwidth" using ADO. ... bottleneck - need to step up to Sql Server. ...
    (comp.databases.ms-access)
  • CoCreateInstance failed!!!!
    ... I am a newbie to oledb programming. ... Creation and accessing of database from Win Ce/ Embedded vc++ MFC based ... ultimate aim is to access a sql server database from sql server ce provider ...
    (microsoft.public.data.oledb)