|
Posted by raylopez99 on 04/01/07 21:14
On Apr 1, 11:45 am, Erland Sommarskog <esq...@sommarskog.se> wrote:
> raylopez99 (raylope...@yahoo.com) writes:
>> See thread here:
> >http://tinyurl.com/3e2nz8
>
> You have a connection string that goes:
>
> connection->ConnectionString = "User ID=sa; Password=;"
> "Data Source=(local); Initial Catalog=DCV_DB;";
>
> But didn't you say you were using SQL Express? By default, SQL Express is
> installed as a named instance with the name SQLEXPRESS, in which case the
> Data Source should be: (local)\SQLEXPRESS.
Yes, but for some reason \SQLEXPRESS doesn't compile in VS2005 "S not
recognized" error
>
> Did the User ID and Password come from that book?
Yes, it was the author's example.
> If you want your app
> to run with Integrated Security, you should use
>
> Integrated Security=SSPI;
>
> instead. Having sa with a blank password is extremely bad practice, and
> outright dangerous if the server is exposed on the Internet.
I'm not sure this database is exposed to the Internet or not (I
believe I checked the \CLR option in SQL Server Management Express,
and intended only local connections but I don't know.
Also of interest: "testing" the database connection (from within
Server Explorer in VS2005) yields "OK" (connected), then clicking on
"Modify Connection" then "Advanced" gives: "Use Windows
Authentication", "Integrated Security = True", "initial catalog =
NAMEofDB", "Data Source = myPCname\SQLEXPRESS, and a bunch of other
parameters such as packet size, etc.
Rather than waste any more of your time (and I thank you for replying--
very helpful), I am going to order a specialized book on programming
for SQL *within* VS2005 (I've already ordered a bunch of SQL generic
books, including this one: Programming Microsoft SQL Server 2005
(Paperback) by Andrew J. Brust (Author)
http://www.amazon.com/Programming-Microsoft-SQL-Server-2005/dp/0735619239/ref=pd_bbs_sr_1/002-3963018-6076804?ie=UTF8&s=books&qid=1175461390&sr=1-1
).
The online help for VS2005 was too specific and not comprehensive
enough--they were talking about setting connection strings, which is
fine once you get more experienced, but all I want to do at the moment
is connect to a existing dB from within a simple console C++
application. I wish they had an example showing how to get a
connection string from all databases 'open' in your local path, which
would have helped, or how to connect to any database that's open in
your 'environment'.
Anyway I think the solution lies in security permissions etc. The
example in the textbook made it look so easy but it's not. As in lots
of programming you can spend days with various permutations or you can
see an exemplar that works, and solve your problem much quicker.
Right now I'm looking for that exemplar and am confident I can find it
eventually.
BTW I recently have picked up the Trojan virus "pushu-A", which is
unusual, and I hope it's not related to this database programming. I
can't imagine how, since the above dB is "using Windows
Authentication" and I have a firewall, so I should not be any less
safe than before, but I don't know.
RL
[Back to original message]
|